minmax_by

enum.minmax_by { |obj| block } â [min, max]
enum.minmax_by â an_enumerator
Instance Public methods

Returns a two element array containing the objects in enum that correspond to the minimum and maximum values respectively from the given block.

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

a = %w(albatross dog horse)
a.minmax_by { |x| x.length }   #=> ["dog", "albatross"]
doc_ruby_on_rails
2015-04-05 01:25:18
Comments
Leave a Comment

Please login to continue.