Junior — Middle
Kuidas Kotlinis kontrollida, kas kaks objekti on sama eksemplar viite kaudu?
sobes.tech AI
Vastus AI-lt
In Kotlin, to check whether two variables point to the same object in memory, the === operator is used. It checks referential equality, unlike ==, which checks structural equality (calls equals()).
Example:
val a = Any()
val b = a
val c = Any()
println(a === b) // true, because b refers to the same object
println(a === c) // false, different objects