Sobes.tech
Junior — Senior

What will the comparison of data class instances output

livecode

Task condition

Determine which output will appear in the console after running the code below.

data class Animal(val name: String) {
    var voice: String? = null
}

fun main() {
    val animal1 = Animal("cat")
    val animal2 = Animal("cat")
    println(animal1 == animal2)
    animal1.voice = "meow"
    animal2.voice = "woof"
    println(animal1 == animal2)
}