Method: Enumerable#duplicates
- Defined in:
- lib/casual_support/enumerable/duplicates.rb
#duplicates ⇒ Enumerable
Returns the first-appearing duplicate of each element, preserving order of appearance.
10 11 12 13 |
# File 'lib/casual_support/enumerable/duplicates.rb', line 10 def duplicates seen = Hash.new(0) self.select{|element| (seen[element] += 1) == 2 } end |