Right, in Java this would work because it does not...
# announcements
j
Right, in Java this would work because it does not use an operator for
equals(Any?)
. So if you do this, the compiler will pick
equals(Value)
because it is more specific:
Copy code
val x = Value(1)
val y = Value(2)
println(x.equals(y))
But in Kotlin, the
==
operator is implemented using operator function
equals(Any?)
, so it will not look for other functions. You can still use the same syntax as in Java though, and then it will work