Domanda

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 ?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top