maxmello
03/20/2019, 1:17 PMobject
does not seem to have a hashCode
oder equals
implementation other than the default from Java’s Object
. I don’t know if this would be breaking things, but wouldn’t something like this make sense? :
override fun hashCode(): Int {
return javaClass.hashCode()
}
override fun equals(other: Any?): Boolean {
if (javaClass != other?.javaClass) return false
return true
}
Use case would be something like an object (e.g. part of a sealed class) being used inside data classes, potentially deeply nested, and then expecting that equals / hashCode work by default for … well equality checks.