/* * call-seq: * enum.max => obj * enum.max {|a,b| block } => obj * * Returns the object in _enum_ with the maximum value. The * first form assumes all objects implement <code>Comparable</code>; * the second uses the block to return <em>a <=> b</em>. * * a = %w(albatross dog horse) * a.max #=> "horse" * a.max {|a,b| a.length <=> b.length } #=> "albatross" */ static VALUE enum_max(obj) VALUE obj; { VALUE result = Qundef; rb_iterate(rb_each, obj, rb_block_given_p() ? max_ii : max_i, (VALUE)&result); if (result == Qundef) return Qnil; return result; }