everyone! I have some class from Java dependency:
public class MyClass {
public MyClass copy() {
....
}
public void init() {
...
}
}
And I want to write a function in my Kotlin class:
fun <T : MyClass> prepareListCopy(objects: List<T>?): List<T>? =
objects?.map { it.copy().apply { init() } }
I want my function to accept and return List of subtypes of MyClass, but IDE shows me this error: Change return type of enclosing function 'KOtlinClass.prepareListCopy' to 'List< MyClass >?'
How can I correctly define generic in this function?