<Why can kotlin.collections.List be passed to meth...
# forum
r
Why can kotlin.collections.List be passed to method that accepts java.util.List? A kotlin.collections.List is statically read-only (i.e. defines no modifying methods) but may be mutable at runtime. On the JVM: val readonlyList: kotlin.collections.List = listOf("a", "b", "c") // At runtime: java.util.Arrays$ArrayList (which is a java.util.List) As long as you stay in Kotlin land, readonlyList is practically immutable, and when you can be confident that a non-malicious function f(list: kotlin.collections.List) will not mutate it when calling f(readonlyList). (A...