Closed Katekko closed 2 years ago
AVOID defining custom equality for mutable classes. Linter rule: avoid_equals_and_hash_code_on_mutable_classes
When you define ==, you also have to define hashCode. Both of those should take into account the object’s fields. If those fields change then that implies the object’s hash code can change.
Most hash-based collections don’t anticipate that—they assume an object’s hash code will be the same forever and may behave unpredictably if that isn’t true.
I'm asking because I'm trying to extend my class from other class that's not immutable.
So I'm wondering why equatable needs to be marked as immutable?