[#1551] Hashes as keys — "Nathaniel Talbott" <nathaniel@...>

I was just playing around with Hash#hash and discovered that you can't use a

13 messages 2003/09/23

Hashes as keys

From: "Nathaniel Talbott" <nathaniel@...>
Date: 2003-09-23 21:21:33 UTC
List: ruby-core #1551
I was just playing around with Hash#hash and discovered that you can't use a
Hash as a key in a hash:

  h = {{} => 'a'}
  p h[{}]

  => nil

Is this intentional? Since hash overrides #==, I expected it to do the same
with #hash, but it appears that it just uses Object#hash, which is different
for every instance.

Thanks,


Nathaniel

<:((><



In This Thread

Prev Next