WhydoesthesignatureofgroupBycontainonlyonegeneric?

This is the method signature:

groupBy[K](f: (A) ? K): immutable.Map[K, Repr]

Shouldn't the following:

groupBy[A, K](f: (A) ? K): immutable.Map[K, Repr]

be more appropriate since its taking a collection of A ?

回答

There is no need to defined [A] type parameter on the methods level, because it's defined on the on class level e.g:

sealed abstract class List[+A]

So when method is declared like this groupBy[K](f: (A) ? K): immutable.Map[K, Repr] A is already known.


以上是WhydoesthesignatureofgroupBycontainonlyonegeneric?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>