From: "David A. Black" Date: 2007-08-21T20:45:05+09:00 Subject: Re: Detecting duplicates in an array, anything in the standa Hi -- On Tue, 21 Aug 2007, Jimmy Kofler wrote: > Duplicates can also be extracted from an array like this: > > > class Array > > def find_dups > uniq.map {|v| (self - [v]).size < (self.size - 1) ? v : nil}.compact > end > > end It's buggy, though: >> [nil,1,2,2,3,nil].find_dups => [2] 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)