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: {"baz", "foo", "bar"}>
> 
> set.add("foo")
> p set # #<Set: {"baz", "foo", "bar"}>
> 
> x.chomp!
> set.add(x)
> p set ##<Set: {"baz", "foo", "bar"}>
> 
> Can anyone demonstrate the bug he is referring to?
> 
> - Dan

irb(main):020:0> s = Set[]
=> #<Set: {}>
irb(main):021:0> a = []
=> []
irb(main):022:0> s << a
=> #<Set: {[]}>
irb(main):023:0> a << 3
=> [3]
irb(main):024:0> s << a
=> #<Set: {[3], [3]}>

-- 
      vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407