From: Mark Van Holstyn Date: 2005-10-17T15:38:33+09:00 Subject: Re: How to get non-unique elements from an array? ------=_Part_70355_30315321.1129531111646 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Zach, if an element repeats more that once, itll double up in the output array. need to add a .uniq on the end irb(main):165:0> a =3D [1,2,3,4,5,3,5,3,5] =3D> [1, 2, 3, 4, 5, 3, 5, 3, 5] irb(main):166:0> t=3D[]; a.delete_if{ |e| r=3D(not t.include? e); t.push(e)= ; r } =3D> [3, 5, 3, 5] That aside, this one is a little shorter, and seems to benchmark a touch faster as well. irb(main):180:0> a=3D[1,2,3,4,5,3,5,3,5] =3D> [1, 2, 3, 4, 5, 3, 5, 3, 5] irb(main):181:0> t=3D[]; a.select{ |e| r=3Dt.include?e; t< [3, 5] irb(main):182:0> a =3D> [1, 2, 3, 4, 5, 3, 5, 3, 5] Mark ------=_Part_70355_30315321.1129531111646--