From: timsuth@... (Tim Sutherland) Date: 2004-03-01T22:14:46+09:00 Subject: Re: UnboundMethod#hash apparently broken in 1.8.1 In article , David Alan Black wrote: >Hi -- > >"Robert Klemme" writes: > >> Hi all, >> >> one can't use UnboundMethod as a hash key: >> >> irb(main):001:0> class Foo; def bar;end; end >> => nil >> irb(main):002:0> Foo.instance_method( :bar ) >> => # >> irb(main):003:0> a = Foo.instance_method( :bar ) >> => # >> irb(main):004:0> b = Foo.instance_method( :bar ) >> => # >> irb(main):005:0> a == b >> => true >> irb(main):006:0> b == a >> => true >> irb(main):007:0> a.hash == b.hash >> => false >> irb(main):008:0> a.id >> => 135052720 >> irb(main):009:0> a.hash >> => 135052720 >> irb(main):010:0> b.id >> => 135044800 >> irb(main):011:0> b.hash >> => 135044800 >> >> UnboundMethod#hash is broken in >> $ ruby --version >> ruby 1.8.1 (2003-12-25) [i386-cygwin] >> >> Is that fixed in a later version? > >I'm not sure why you describe it as broken. Can you explain >a little further? I think he means because "a == b" but "!a.eql?(b)" and "a.hash != b.hash". It's not a bug, just a lack of a feature. I posted a similar message today about Sets. -- Tim Sutherland 2004 SDKACM President Software Developers' Klub - the University of Auckland ACM Student Chapter http://www.sdkacm.com/