[#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

Re: Hashes as keys

From: Jason Creighton <androflux@...>
Date: 2003-09-24 02:40:01 UTC
List: ruby-core #1560
On Wed, 24 Sep 2003 08:05:21 +0900
Joel VanderWerf <vjoel@PATH.Berkeley.EDU> wrote:

> Nathaniel Talbott wrote:
> 
> > The underlying question is, why do two Hashes with the same content have
> > different hash values?:
> 
> I'd like to know, too. Maybe a hash is thought of as an object with 
> attributes, rather than just a collection.

That appears to be the case. For instance, a Hash with the cool "block
default value" is != to another hash:

>> h1 = Hash.new { |h,k| k*2 }
=> {}
>> h2 = Hash.new
=> {}
>> h1 == h2
=> false

Jason Creighton

In This Thread