Possible Duplicate:
What do <:<, <%<, and =:= mean in Scala 2.8, and where are they documented?
e.g. in this example, from scala-arm 1.0:
def toTraversable[B](implicit ev: R <:< TraversableOnce[B]): Traversable[B] =
new ManagedTraversable[B,R] {
val resource = self
override protected def internalForeach[U](resource: R, g : B => U) : Unit =
ev(resource).foreach(g)
}
<:<
(and similar strange looking constructs) are defined in Predef.scala (source at scala-lang.org), which is probably the best resource for working out what they are.
In general, classes like that can be used to provide further bounds on the type parameters within the scope of a particular method.
The <:<
in particular is used to require that R
is a subtype of TraversableOnce[B]
.
The description from documentation is:
An instance of
A <:< B
witnesses thatA
is a subtype ofB
. Requiring an implicit argument of the typeA <:< B
encodes the generalized constraintA <: B
.To constrain any abstract type
T
that's in scope in a method's argument list (not just the method's own type parameters) simply add an implicit argument of typeT <:< U
, whereU
is the required upper bound; or for lower-bounds, use:L <:< T
, whereL
is the required lower bound.