kotlin variance works strangely in generic function
Here is the code
fun main() {
val sr = mutableListOf(1,2,3)
val des = mutableListOf()
copyData(sr, des)
des.forEach { println(it) }
}
fun copyData( source: MutableList< out T>,
destination: MutableList< T>) {
for (item in source) {
destination.add(item)
}
}
In the above code MutableList< out T> makes MutableList covariant. Ok, I understand this. But if I change the function signature and have this:...