【发布时间】:2016-02-17 19:15:26
【问题描述】:
我是 Scala 新手,我正在使用无形库来操作元组。 (虽然这不是特定于无形的)
我遇到了一个与隐式参数相关的问题,我不太明白。这里有签名:
def reverse(implicit reverse: Reverse[T]): reverse.Out = reverse(t)
def drop[N <: Nat](implicit drop: Drop[T, N]): drop.Out = drop(t)
这是正在使用的:
val foo = ("foo","bar","other").reverse
val bar = ("foo","bar","other").drop(1)
但是在 Scala 2.10 上我得到了这个错误:
错误:(25, 37) 找不到参数反向的隐式值: shapeless.ops.tuple.Reverse[(String, String, String)] val zzy = ("foo","bar","other").reverse
错误:(29, 37) 方法反转的参数不足: (隐式 反向:shapeless.ops.tuple.Reverse[(字符串,字符串, 字符串)])reverse.Out。未指定值参数反转。 val foo = ("foo","bar","other").reverse
^
我不确定它试图引用的隐式参数是什么,或者我为什么需要它。此外,这似乎适用于 2.11(但 IntelliJ 标记它)
【问题讨论】:
标签: scala