Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Range#minmax

rng.minmax → [obj, obj]
rng.minmax {| a,b | block } → [obj, obj]

Returns a two element array which contains the minimum and the maximum value in the range.

Can be given an optional block to override the default comparison method a <=> b.

See also #min #size #member? #step also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1