Module: Gemmy::Patches::ArrayPatch::InstanceMethods::Duplicates

Defined in:
lib/gemmy/patches/array_patch.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.autotestObject



126
127
128
# File 'lib/gemmy/patches/array_patch.rb', line 126

def self.autotest
  [1,1,2,2,3].duplicates == [1,2]
end

Instance Method Details

#duplicates(min = 2) ⇒ Object

facets



119
120
121
122
123
124
125
# File 'lib/gemmy/patches/array_patch.rb', line 119

def duplicates(min=2)
  h = Hash.new( 0 )
  each {|i|
    h[i] += 1
  }
  h.delete_if{|_,v| v < min}.keys
end