使用简单类型的隐式值的便捷方法是什么?理想情况下,我想做这样的事情:
scala> :paste
// Entering paste mode (ctrl-D to finish)
type A = String
type B = String
implicit val a: A = "a"
implicit val b: B = "b"
def c(implicit ab: A) = println(ab)
// Exiting paste mode, now interpreting.
defined type alias A
defined type alias B
a: A = a
b: B = b
c: (implicit ab: A)Unit
scala> c
<console>:13: error: ambiguous implicit values:
both value a in object $iw of type => A
and value b in object $iw of type => B
match expected type A
也不能子类化最终案例类,如 String 或 Long
scala> class C extends String
<console>:11: error: illegal inheritance from final class String
class C extends String