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]
range.c
View on GitHub ↗
static VALUE
range_minmax(VALUE range)
{
if (rb_block_given_p()) {
return rb_call_super(0, NULL);
}
return rb_assoc_new(
rb_funcall(range, id_min, 0),
rb_funcall(range, id_max, 0)
);
}
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.