Hard
Considering :
open class Animal
data class Cat(val name : String = "Kitty") : Animal()
The following code :
val cats: MutableList<Cat> = mutableListOf(Cat("Isidor"), Cat("Garfield"), Cat("Rogue"))
val animals: List<Animal> = cats
cats.add(Cat())
animals.forEach({ print(it) })
Author: W3D TeamStatus: PublishedQuestion passed 529 times
Edit
Similar QuestionsMore questions about Kotlin