Module: Enumerable
- Defined in:
- lib/core_ext/enumerable.rb
Overview
Extends Ruby’s own Enumrable module with method #max_by? for Ruby < 1.8.7
Instance Method Summary collapse
-
#max_by {|obj| ... } ⇒ Object
Returns the object in enum that gives the maximum value from the given block.
Instance Method Details
#max_by {|obj| ... } ⇒ Object
Returns the object in enum that gives the maximum value from the given block.
21 22 23 |
# File 'lib/core_ext/enumerable.rb', line 21 def max_by(&block) max { |a , b| block.call(a) <=> block.call(b) } end |