From: Andrew Walrond Date: 2005-05-05T22:28:20+09:00 Subject: Re: Fwd: Re: Whats so different about a Hash? On Thursday 05 May 2005 13:57, ts wrote: > >>>>> "A" == Andrew Walrond writes: > > A> $ ruby --version > A> ruby 1.8.2 (2004-11-27) [i686-linux] > > Can you update to the latest stable > See other message - same result as you. But is this the _correct_ behaviour? The reason this came up was because I wanted to use hashes as keys in hashes. Consider: irb(main):001:0> a={} => {} irb(main):002:0> a[{1=>2}]=3 => 3 irb(main):003:0> a[{1=>2}]=3 => 3 irb(main):004:0> a[{1=>2}]=3 => 3 irb(main):005:0> a.inspect => "{{1=>2}=>3, {1=>2}=>3, {1=>2}=>3}" but irb(main):018:0> a={} => {} irb(main):019:0> a[[1,2]]=3 => 3 irb(main):020:0> a[[1,2]]=3 => 3 irb(main):021:0> a[[1,2]]=3 => 3 irb(main):022:0> a.inspect => "{[1, 2]=>3}" Not at all what I was expecting! Is there a good reason why irb(main):029:0> [1,2]==[1,2] => true irb(main):030:0> [1,2]===[1,2] => true irb(main):031:0> [1,2].eql?([1,2]) => true but irb(main):033:0> {1=>2}=={1=>2} => true irb(main):034:0> {1=>2}==={1=>2} => true irb(main):035:0> {1=>2}.eql?({1=>2}) => false ? Andrew