Imagine two hashes that are clearly different:
hash_a[:donkey]
# => 5
hash_b[:donkey]
# => 10
Yet:
hash_a == hash_b
# => true
How is this possible, when both hash_a
and hash_b
are instances of Hash
, without monkeypatching anywhere?
Answer: default values!
hash_a = Hash.new(5)
hash_b = Hash.new(10)
Strangely, the default value is ignored when comparing hashes.
Come to the Go side of the force, Denis.