我该如何理解这句话"two instances with the same hash value don’t necessarily compare equally. "

How can I comprehend this sentence "two instances with the same hash value don’t necessarily compare equally. "

当我阅读《进阶》Swift 和第 'Hashable Requirement' 章时,我被这个解释弄糊涂了

two instances that are equal (as defined by your == implementation) must have the same hash value. The reverse isn’t true: two instances with the same hash value don’t necessarily compare equally.

我如何理解'reverse'的情况,或者为什么具有相同哈希值的两个实例不一定相等。

将散列值视为快速紧凑非唯一标识符对于给定的对象实例。唯一的硬条件是:如果两个对象比较相等,根据 == 运算符,那么两个实例 必须 具有完全相同的哈希值。仅此而已 ;)

特别是,鉴于散列值不是唯一的——如何给它们 Int 有限的范围? — 我们不能安全地假设具有相同哈希值的两个实例将进行相等比较。