The fact that x
has different hash value than y
implies that x != y
. But the converse is not true! So when x
has hash value equal to y
they are still checked for equality explicitly.
A situation when hash(x) == hash(y)
and x != y
is called a collision in the context of hash functions and is something that's likely to happen from time to time. You want to avoid it as much as possible but in general it is inevitable. You can read more about hash functions and collisions here.