horse_badorties
08/22/2017, 11:24 AMequals
like this?
class Foo(val name: String) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Foo
if (name != other.name) return false
return true
}
}
Why not simply using is
?
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Foo) return false
if (name != other.name) return false
return true
}
Is there a catch?