Thread
#stdlib
    Rob Elliot

    Rob Elliot

    4 months ago
    hashCode doesn't necessarily identify a unique object.
    It's perfectly valid for two different instances to have the same hashCode.
    e

    ephemient

    4 months ago
    the rule is that if two instances equal each other (via
    .equals()
    , which is
    ==
    in Kotlin (except for NaN which we'll ignore here)), then they must have the same
    hashCode()
    . this implies the contrapositive (if two instances have different
    hashCode()
    then they must not be
    ==
    ), but does not imply the converse: it is allowed for two instances to have the same
    hashCode()
    but be
    !=
    and of course, as Rob brings up, the same
    hashCode()
    can be returned by
    !==
    instances (I'm just clarifying that it must be, for
    ==
    instances)