From: Robert Dober Date: 2010-06-04T18:31:21+09:00 Subject: Re: comparing objects On Fri, Jun 4, 2010 at 10:16 AM, Marcin Wolski wrote: > Robert Dober wrote: >> On Fri, Jun 4, 2010 at 3:41 AM, Marcin Wolski wrote: >> >>> �def ==(other) >>> �@email == other.email >>> �end >> this seems ok >>> >>> �alias eql? == >>> >>> �def hash >>> � �code = 17 >>> � �code = 37*code + @email.hash >>> end >>> >> Are you sure you want to do this? "equal" objects would overwrite each >> other when used as hash keys. This is normally not a good idea, be >> sure you really want/need this! >> R > > What would be the other possible solution to this problem? The example > code will not work without overwritten eql? and hash methods. > -- > Posted via http://www.ruby-forum.com/. > Does it not? Seems to work on my box class A def == other true end end # class A a1 = A::new a2 = A::new a3 = A::new p [a1,a2] & [a1,a3] -- The best way to predict the future is to invent it. -- Alan Kay