Method: Range#minmax

Defined in:
range.c

#minmaxArray #minmax {|a, b| ... } ⇒ Array

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.

Overloads:

  • #minmaxArray

    Returns:

  • #minmax {|a, b| ... } ⇒ Array

    Yields:

    • (a, b)

    Returns:

[View source]

1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
# File 'range.c', line 1297

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)
    );
}