From: Daniel Berger Date: 2003-04-08T22:54:25+09:00 Subject: Re: Array Sutraction Jim Freeze wrote: > > Ok, this has been discussed at length previously, > and it appears that the implementation has > changed. > > Consider: > > # in 1.6.7 > [1,1,2,2,3,3] - [3] => [1,2] > > # in 1.8.0 > [1,1,2,2,3,3] - [3] => [1,1,2,2] > > I think this last algorithm was chosen for > performance reasons. The problem is, the #- operation > is neither explainable by the Array being considered a bag > or a set. Plus, since this operation seems to change > with revisions, it is hard to rely upon. FWIW, 1.8 has a Set class if you want true set behavior: require "set" set_a = Set.new([1,1,2,2,3,3]) p set_a -> # set_b = set_a -[3] p set_b -> # Regards, Dan -- a = [74, 117, 115, 116, 32, 65, 110, 111, 116, 104, 101, 114, 32, 82] a.push(117,98, 121, 32, 72, 97, 99, 107, 101, 114) puts a.pack("C*")