On 10/15/05, Sam Kong <sam.s.kong / gmail.com> 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.

You don't need the exact number of repetitions. Try this:
a = [0,1,2,3,4,5,2,3]
h = {}
u = a.inject([]) {|res, x| h[x] ? res + [x] : h[x] = res}

Paolo