From: mgarriss Date: 2003-08-27T02:09:45+09:00 Subject: Re: Array#uniq! Kurt M. Dresner wrote: >The exclamation point usually means that the array is modified in place, >and thus its return value should not be the uniquified array, but rather >something that can tell you if the array elements were unique, and if >not, what elements were responsible. > >That way, you can say something like: > >a = some stuff > >if b = a.uniq! > puts "array was unique." >else > puts "array was not unique: multiple instances of " + b.join(', ') >end > >That is a whole lot better than having to store a copy of the old array >and then do set subtraction with the uniquified array. > >-Kurt > I'll just use '(a = a.uniq).some_method' to keep it in place. In my case the array is tiny and this is done very rarely so no performance hit.