Why is it `interface Comparator<T>` instead ...
# stdlib
j
Why is it
interface Comparator<T>
instead of
interface Comparator<in T>
? Like, I know theoretically you shouldn't have to specify that the
T
has
in
variance, but in common code errors will be shown if you do something like
interface Sort<in T>: Comparator<T>
, saying the
T
in
Comparator
is
invariant
.
i
In JVM
Comparator
interface is implemented with
java.util.Comparator
which is invariant, that's why it's invariant in common too.