From: Mauricio Fernandez Date: 2007-01-30T17:20:27+09:00 Subject: Re: Sane #hash implementation? On Tue, Jan 30, 2007 at 05:10:51PM +0900, Eric Hodel wrote: > On Jan 29, 2007, at 23:26, Shot (Piotr Szotkowski) wrote: > >Eric Hodel: > >>On Jan 29, 2007, at 14:38, Shot (Piotr Szotkowski) wrote: > >>>I’m stuck when it comes to Block#hash, though; I need these to be > >>>true: > >>>Block.new.hash == Block.new.hash > >>>Block.new([1,2]).hash == Block.new([1,2]).hash > > > >>Try: > > > >>class Block > >> def hash > >> to_a.hash > >> end > >>end > > > >Thanks a lot, Eric! This is the ‘d’oh!’ solution I was looking for. > >:) > > You may want to define #eql? in terms of #to_a as well... That would fail for the same reason as your Block#hash. -- Mauricio Fernandez - http://eigenclass.org - singular Ruby