Flowdock
min_by(p1 = v1) public

Returns the object in enum that gives the minimum value from the given block.

If no block is given, an enumerator is returned instead.

a = %w(albatross dog horse)
a.min_by { |x| x.length }   #=> "dog"

If the n argument is given, minimum n elements are returned as an array. These n elements are sorted by the value from the given block.

a = %w[albatross dog horse]
p a.min_by(2) {|x| x.length } #=> ["dog", "horse"]
Show source
Register or log in to add new notes.