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



139
140
141
# File 'lib/gemmy/patches/array_patch.rb', line 139

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

Instance Method Details

#duplicates(min = 2) ⇒ Object

facets



132
133
134
135
136
137
138
# File 'lib/gemmy/patches/array_patch.rb', line 132

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