From: Robert Klemme Date: 2007-08-21T17:22:37+09:00 Subject: Re: Detecting duplicates in an array, anything in the standa 2007/8/21, Pe�a, Botp : > From: Jimmy Kofler [mailto:koflerjim@mailinator.com] > # uniq.map {|v| (self - [v]).size < (self.size - 1) ? v : nil}.compact > > cool. > could we simplify it like, > > irb(main):014:0> a > => [1, 1, 2, 2, 2, 4, 3] > irb(main):015:0> a.select{|e| (a-[e]).size < a.size - 1}.uniq > => [1, 2] Nice! But I'd think this is more efficient: irb(main):001:0> a = [1, 1, 2, 2, 2, 4, 3] => [1, 1, 2, 2, 2, 4, 3] irb(main):002:0> a.uniq.select{|e| (a-[e]).size < a.size - 1} => [1, 2] Kind regards robert