문제

If I write:

class T
implicit val m = Map[String, Map[T, Int]]()
"123"(0)

it complains with:

<console>:10: error: type mismatch;
  found   : Int(0)
  required: T
          "123"(0)

But it should return '1'. All that I understand is that not only m is implicit, but also m.apply. Why is it so ?

도움이 되었습니까?

해결책

Map[A,B] is a A => B, so scala converts your string to your Map[T, Int].

This has been complained about on the MLs.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top