From: Christoph Rippel Date: 2001-02-23T13:56:57+09:00 Subject: [ruby-talk:11364] Re: Array bugs? > From: ts [mailto:decoux@moulon.inra.fr] [...] > C> same problem is probably also in hash - and it extends > > Not yet found ruby -e 'a={};a[a] = a; b ={}; b[a] = b; b == a' > > C> to arrays which contain object with non-id based #== > C> methods. > > Do you have an example for this. class UnOrderedPair def ==(other) return false unless other.kind_of? UnOrderedPair return true if id == other.id return true if (@l == other.l ) && (@r == other.r) return (@l == other.r ) && (@r == other.l) end def initialize(ll,rr) @l = ll; @r = rr end protected attr_reader :l, :r end l = []; r=[] pl = UnOrderedPair.new l,r pr = UnOrderedPair.new r,l l << pl; r << pr pl == pr Christoph