From: Martin DeMello Date: 2005-10-17T16:36:57+09:00 Subject: Re: How to get non-unique elements from an array? 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. Without counting: h1 = {} h2 = {} a.each {|i| h2[i] = true if h1[i] h1[i] = true } p h2.keys martin