From: "Berger, Daniel" Date: 2005-10-18T00:37:30+09:00 Subject: Re: Set.new vs Set[] > -----Original Message----- > From: Damphyr [mailto:damphyr@freemail.gr] > Sent: Saturday, October 15, 2005 2:48 PM > To: ruby-talk ML > Subject: Re: Set.new vs Set[] > > > Daniel Berger wrote: > > Hi all, > > > > Ruby 1.8.3 > > > > irb(main):001:0> require "set" > > => true > > > > irb(main):002:0> a = [0,1,2,3,4,5,2,3] > > => [0, 1, 2, 3, 4, 5, 2, 3] > > > > irb(main):003:0> set1 = Set.new(a) > > => # > > > > irb(main):004:0> set2 = Set[a] > > => # > > > > Shouldn't the set returned by Set[] also be only the unique values? > Nope, you just made a Set with an array as an element in the > second example. In the first one you have the elements of the > array inserted in the set, > not the array itself. > Cheers, > V.- Whoops, you're right. I should have noticed that. Anyway, I think I'll submit a documentation patch, since the difference between Set[] and Set.new isn't very well spelled out (to me, anyway). Thanks. Dan