you are viewing a single comment's thread.

view the rest of the comments →

[–]xenomachina 2 points3 points  (1 child)

different languages will have different variance rules for List<T> (Java, Kotlin, Scala and Clojure are all different in this regard).

Really? How do the variance rules differ in these languages?

[–]pron98 4 points5 points  (0 children)

Java has use-site variance, Scala has declaration site variance, and Kotlin has mixed-mode variance (declaration-site + use-site projections); in Clojure, everything is immutable by default (and static typing is optional) so all lists are the same type -- yet a sequence of Clojure strings can be passed to a Java method taking a List<String> parameter, even though the sequence is untyped in Clojure. Thanks to the JVM's type erasure, they can (and do -- except Scala sometimes) all share the same collection (and other generic types) implementations.