The trait Map[A,+B] has a method
def minBy [B] (f: ((A, B)) ⇒ B)(implicit cmp: Ordering[B]): (A, B)
I expected the B of the trait to be the same as the one in the method, but then I can’t still make sense of this:
val m2 = Map('a -> "1", 'b ->"2" ,'c ->"3")
m2.minBy((t:(Symbol,String))=>Integer.parseInt(t._2))
Here, B of Map[A,+B] is String, but B of minBy is Int – or err I?
So I expected the type of the method to be rather
def minBy [C] (f: ((A, B)) ⇒ C)(implicit cmp: Ordering[C]): (A, B)
But thats not what the source says.
If both are distinct, where should I have known?
If they are not – can you spot, and point out, my mistake?
You analysis is correct, it should be renamed as C, or something else. The problem is that scaladoc is simply replacing the A in the definition in TraversableLike with a Tuple (A, B) because it’s a map. This is the definition from TraversableLike:
because it’s a map, scaladoc replaces the (A) with a tuple (A, B).
which as you observe, isn’t actually the correct signature.
This is a known issue, scaladoc does not disambiguate between same-named type parameters. Vote it up or submit a patch!