It says in the documentation to hash function
“Any hash value that exceeds the capacity of a Fixnum will be truncated
before being used.”
From this I understand that it’s OK for my object to return a Bignum.
irb(main):117:0> def o.hash;89624894967898529964558;end
RangeError: bignum too big to convert into
long' from (irb):119:inhash’
My o can be used as a key in Hash but computing the hash of Array with
it inside fails. So now:
- Isn’t it inconsistent with the description? It says that hash will be
truncated before being used, so it should be truncated before being used
to calculate the hash of the array.
- What is the walkaround? How to check if a value has already exceeded
the capacity of Fixnum, and how to truncate it manually?
It was TPR speaking, from Ruby 1.9.1p0 on Windows, thanks for listening.