So I've been trying to learn Scala through the twitter Scala school. But I'm currently stuck at one of their type bound examples.
In particular, it's the one where the type is bound to be viewable as a certain type, using the <%<
type-relation operator.
When I execute the following code in my Scala console:
scala> class Container[A](value: A) { def addIt(implicit evidence: A <%< Int) = 123 + value }
... I get the following errors:
<console>:7: error: not found: type <%<
class Container[A](value: A) { def addIt(implicit evidence: A <%< Int) = 123 + value }
^
<console>:7: error: overloaded method value + with alternatives:
(x: Double)Double <and>
(x: Float)Float <and>
(x: Long)Long <and>
(x: Int)Int <and>
(x: Char)Int <and>
(x: Short)Int <and>
(x: Byte)Int <and>
(x: String)String
cannot be applied to (A)
class Container[A](value: A) { def addIt(implicit evidence: A <%< Int) = 123 + value }
My question is, why is the Scala interpreter complaining?
I've been trying to look through the Scala documentation but I haven't been able to find information that operator anywhere. I can see that the Scala school was created on the basis of Scala 2.8.0, and I'm running Scala 2.10.0 - so maybe this have been removed? If this is the case, why is this as it seems like a useful operator?