Computer scienceProgramming languagesKotlinObject-oriented programmingGenerics

Variance

Theory

Copy a List

Report a typo

We have the following code, please complete it to copy an object of Person or any subtype of Person:

open class Person
class Student : Person()
class Teacher : Person()

fun <T> copyList(/* write your code here */, destination: MutableList<T>) {
    destination.addAll(source)
}
Enter a short text
___

Create a free account to access the full topic