Module: Gemmy::Patches::ArrayPatch::InstanceMethods::Mode

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

Instance Method Summary collapse

Instance Method Details

#modeObject

facets



190
191
192
193
194
195
# File 'lib/gemmy/patches/array_patch.rb', line 190

def mode
  max = 0
  c = Hash.new 0
  each {|x| cc = c[x] += 1; max = cc if cc > max}
  c.select {|k,v| v == max}.map {|k,v| k}
end