Search code examples
kotlintornadofx

Contradiction - equal entities are not equal


Please have a look at the fragment of kotlin tornadofx code:

println(costTable[1].numberGoodProperty)
println(SimpleIntegerProperty(objC.number))
val max11 = if (costTable[1].numberGoodProperty == SimpleIntegerProperty(objC.number)) 1 else 0
println("max11 $max11")

And this is the printout:

IntegerProperty [value: 2]

IntegerProperty [value: 2]

max11 0

Can anyone explain this?


Solution

  • As far as I see SimpleIntegerProperty doesn't have the appropriate equals method so it uses Object.equals which just compares links to the objects. You have two distinct links so they are not equal