Oops, sorry, uniq! doesn't return a count, but it doesn't return the
resulting array, either, UNLESS there were duplicates...

~/p/ruby/vcard $ irb
irb(main):001:0> ["a"].uniq!
nil
irb(main):002:0> ["a", "a"].uniq!
["a"]
irb(main):003:0> ["a"].uniq
["a"]
irb(main):004:0> ["a", "a"].uniq
["a"]

Quoteing sroberts / uniserve.com, on Thu, Feb 13, 2003 at 01:32:42PM +0900:
> 
> I wanted to remove all nils and duplicate values from an array:
> 
>   ...
>   @fields.collect{ |field| field.group }.compact!.uniq!
> end
> 
> I wanted to modify in place, because the return value of collect() is
> ephemeral, nobody else can have a reference, no need to duplicate it, I
> thought...
> 
> But now I have:
> 
>   all = @fields.collect{ |field| field.group }.compact!
>   all.uniq!
>   all
> end
> 
> 
> Should I just do:
> 
>   @fields.collect{ |field| field.group }.compact.uniq
> 
> Doesn't this create an array,
> create a new array without nils,
> throw away the old,
> create a new array without duplicates,
> and throw away the old
> ??
> 
> Should I not worry about it?
> 
> Sam
> 
>