From: "David A. Black" Date: 2005-10-17T00:51:57+09:00 Subject: Re: How to get non-unique elements from an array? Hi -- On Sun, 16 Oct 2005, Sam Kong wrote: > Hello! > > 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. > > a = [0,1,2,3,4,5,2,3] > > #What I want to get is [2,3] as 2,3 are non-unique elements. One probably slow but kind of cool way is: a.uniq.find_all {|x| a.find_all {|y| y == x }.size > 1 } David -- David A. Black dblack@wobblini.net