Consulting types of arguments in first parameter list

So if you take a look to the scaladoc, you will see that the signature of sortWith is as follows:

def sortWith(lt: (A, A) => Boolean): List[A]

So it doesn’t have to infer anything, since A is the type parameter of the List and since we already know that it is a List of Chars then we already know that A is Char.
So the compiler will simply type check that the function does accept two Chars and return a Bolean. And since _ > _ is expanded as (a: Char, b: Char) => a > b then it does.

1 Like