Method: Enumerable#minmax
- Defined in:
- enum.c
#minmax ⇒ Array #minmax {|a, b| ... } ⇒ Array
Returns two elements array which contains the minimum and the maximum value in the enumerable. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b.
a = %w(albatross dog horse)
a.minmax #=> ["albatross", "horse"]
a.minmax {|a,b| a.length <=> b.length } #=> ["dog", "albatross"]
1272 1273 1274 |
# File 'enum.c', line 1272 static VALUE enum_minmax(obj) VALUE obj; |