Method: Enumerable#max_by

Defined in:
enum.c

#max_by {|obj| ... } ⇒ Object

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

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

Yields:

  • (obj)

Returns:



1368
1369
1370
# File 'enum.c', line 1368

static VALUE
enum_max_by(obj)
VALUE obj;