From: Rick DeNatale Date: 2006-09-21T23:35:18+09:00 Subject: Re: Bug in Hash#hash? (Ruby 1.8.4) On 9/21/06, Eyal Oren wrote: > Yukihiro Matsumoto wrote: > >> |say one = {:a=>:b} > >> |then one.hash != one.clone.hash > >> |is that a bug or correct? > > Currently it's an intended behavior. Hash is not designed to be hash > > key (two hashes are considered to be a same key if they are exactly > > the same object). > is it not useful to have a hash as hash-key? I often use hashes to > emulate named parameter-values, and if I have say a connection pool I > would like to index it based on the connection-parameters (which are > given as a hash of key-value pairs). Not entirely to the point, but... One issue you have to be aware of if you have a Hash with keys that are mutable, is that if a key mutates so as to affect the results of eql?/hash then the hash needs to be rehashed or strange events can ensue. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/