From: "David A. Black" Date: 2007-08-21T01:06:38+09:00 Subject: Re: Detecting duplicates in an array, anything in the standard library ? Hi -- On Tue, 21 Aug 2007, Gabriel Dragffy wrote: > > On 20 Aug 2007, at 14:50, Robert Klemme wrote: > >>> >>> require 'set' >>> >>> new_ary = ary.to_set.to_a #set strips dups. >> >> It does, but as far as I can see OP wanted exactly the duplicates back. >> >> Cheers >> >> robert >> > > > I'm a n00b, sorry if I'm poking nose in. Couldn't the op do something using > &, like so: > > [1,2,3] & [2,3,4] == [2,3] The original question was how to get all dups occurring in one array: [1,2,3,2,4,5,5,6] => [2,5] David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)