method

minmax_by

v1_9_1_378 - Show latest stable - Class: Enumerable
minmax_by()
public

Returns two elements array array containing the objects in enum that gives the minimum and maximum values respectively from the given block.

a = %w(albatross dog horse)
a.minmax_by {|x| x.length }   #=> ["dog", "albatross"]