Method: Enumerable#maximum

Defined in:
lib/active_support/core_ext/enumerable.rb

#maximum(key) ⇒ Object

Calculates the maximum from the extracted elements.

payments = [Payment.new(5), Payment.new(15), Payment.new(10)]
payments.maximum(:price) # => 15


40
41
42
# File 'lib/active_support/core_ext/enumerable.rb', line 40

def maximum(key)
  map(&key).max
end