Possible Duplicate:
What do <:<, <%<, and =:= mean in Scala 2.8, and where are they documented?
I’m curious since I saw them in Scala library code, but I found it quite hard to Google something about them since their names are not words.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
These classes are used for implicit parameters that restrict the applicability of a method. Below is a description of each class. In general they are useful to restrain the a type parameter of an enclosing class within the context of a single method.
<:<[A,B]orA <:< BThe compiler can provide an implicit instance of this type only when A is a subtype of B. This is similar to
A <: Bin a type parameter list.This can be useful when you want to put an additional constraint on a class type parameter in the context of a particular method. For example the class
Foobelow can be used with any type, but the methodbaris only valid whenTis a subtype ofNumber.=:=[A,B]orA =:= BThe compiler can provide an implicit instance of this type only when A is the same type as B. This doesn’t have an equivalent syntax in a type parameter list, you’d just use the same type parameter twice.
This can be used much like
<:<except that it requires the types to match exactly. This could be used to make a pair of methods mutually exclusive.Essentially if the type parameter is more specific than the constraint you can force the more specific method to be used.
<%<[A,B]orA <%< BThe compiler can provide an implicit instance of this type only when A can be converted to B. This is similar to
A <% Bin a type parameter list.This requires that there is an implicit function available to turn an A into a B. This will always be possible when
A <: Bsince the implicitA <:< Bsatisfies this constraint.This class is actually marked as deprecated. It says you should instead just use
A => B.