From: Simon Strandgaard Date: 2005-10-16T03:31:15+09:00 Subject: Re: How to get non-unique elements from an array? On 10/15/05, Sam Kong wrote: > I need to get non-unique elements from an array. > The best I came up with was using a hash as a counter for each unique > elements. How about? ary = [1, 1, 2, 3, 3, 4, 2, 5, 7] #=> [1, 1, 2, 3, 3, 4, 2, 5, 7] uary = ary.uniq; ary.map.delete_if{|i| x=uary.member?(i); uary.delete(i); x} #=> [1, 3, 2] -- Simon Strandgaard