使用簡單類型的隱式值的便捷方式是什麼?理想情況下,我願做這樣的事情:使用結構類型的含義
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
人們不能繼承像字符串或長任
scala> class C extends String
<console>:11: error: illegal inheritance from final class String
class C extends String
+1教我'左右:paste' –