From: Joel VanderWerf Date: 2006-02-09T08:41:09+09:00 Subject: Re: [ ruby-Bugs-3506 ] Set containing duplicates Daniel Berger wrote: > noreply@rubyforge.org wrote: >> Bugs item #3506, was opened at 2006-02-08 22:52 >> You can respond by visiting: >> http://rubyforge.org/tracker/?func=detail&atid=1698&aid=3506&group_id=426 >> >> Category: Core >> Group: None >> Status: Open >> Resolution: None >> Priority: 3 >> Submitted By: Stefan Rusterholz (rstefan) >> Assigned to: Nobody (None) >> Summary: Set containing duplicates >> >> Initial Comment: >> If an object added to a set becomes modified and added again it will >> be in the set twice. >> A fix to this would be to add "@hash.rehash" in "def add(o)" and "def >> merge(enum)". Though this might minder the speed advantage of set. >> OTOH Set becomes quite useless if it is impossible to add without >> checking first if the element already contained. > > I don't see it: > > require "set" > > x = "foo" > > set = Set[x,"bar","baz","foo"] > p set # # > > set.add("foo") > p set # # > > x.chomp! > set.add(x) > p set ## > > Can anyone demonstrate the bug he is referring to? > > - Dan irb(main):020:0> s = Set[] => # irb(main):021:0> a = [] => [] irb(main):022:0> s << a => # irb(main):023:0> a << 3 => [3] irb(main):024:0> s << a => # -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407