hooliooo
04/25/2022, 8:46 AMRoukanken
04/25/2022, 8:53 AMare equal => have same hashCode
you mentioned. (For example HashMap)
One example of such situation is, if you make a data class and override equals (for example to ignore a property), and not override hashCode
to match it (to ignore it too).
TL;DR: yes, but only if data class is wrong. Don't do it.Roukanken
04/25/2022, 8:56 AMRandom.nextInt
)hooliooo
04/25/2022, 8:59 AMoverride fun hashCode(): Int = super.hashCode()
And that data class's parent also implements:
override fun hashCode(): Int = super.hashCode()
Does calling super.hashCode() mess with the hashCode? I find that weirdbezrukov
04/25/2022, 9:38 AMsuper
points to Any, than it produces identity hashcode (which has nothing to do with object's content)Roukanken
04/25/2022, 10:03 AMhooliooo
04/25/2022, 10:07 AM