所以我一直试图通过twitter Scala school来学习Scala。但我目前卡在type bound examples之一。获取Scala类型绑定错误:未找到:类型<%<
特别是,它是使用<%<
类型关系运算符将类型绑定为某种类型的可视类型。
当我在斯卡拉控制台执行以下代码:
scala> class Container[A](value: A) { def addIt(implicit evidence: A <%< Int) = 123 + value }
...我收到以下错误:
<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 }
我的问题是,为什么斯卡拉解释抱怨?
我一直在寻找通过Scala文档,但我一直无法找到任何地方的操作员的信息。我可以看到斯卡拉学校是基于Scala 2.8.0创建的,而且我正在运行Scala 2.10.0 - 所以也许这已被删除?如果是这种情况,为什么这看起来像一个有用的操作符?
看起来这是不是在Scala 2.10,但我不确定为什么 - https://github.com/scala/scala/blob/v2.10.0/src/library/scala/Predef.scala #L1 – Impredicative 2013-02-20 15:37:58
已在https://github.com/scala/scala/commit/e1780e9686914d835b295e125511368eeb1d0733#L0L350 – Debilski 2013-02-20 16:38:37
中弃用!看起来正是我在下面猜测的原因。 – Impredicative 2013-02-20 16:58:11