1

Many guids in which try to explain differences between ? extend T and ? super T use as example method java.util.Collections#copy

public static <T> void copy(List<? super T> dest, List<? extends T> src) {
}

How this method should look in kotlin? If i try to copy and past this method in Kotlin class and convert to kotlin by IntelliJ Idea when this method look like

fun <T> copy(dest: List<in T?>?, src: List<T?>?) {}

But this code not compiled.

pe4enko
  • 354
  • 4
  • 14

1 Answers1

0

Kotlin List are not mutable. See this post

fun <T> copy(
    dest: MutableList<in T>,
    src: List<T>
) {
}
aiqency
  • 1,015
  • 1
  • 8
  • 22