Method: Range#to_a
- Defined in:
- range.c
permalink #to_a ⇒ Array #entries ⇒ Array
Returns an array containing the items in the range.
(1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
(1..).to_a #=> RangeError: cannot convert endless range to an array
830 831 832 833 834 835 836 837 |
# File 'range.c', line 830
static VALUE
range_to_a(VALUE range)
{
if (NIL_P(RANGE_END(range))) {
rb_raise(rb_eRangeError, "cannot convert endless range to an array");
}
return rb_call_super(0, 0);
}
|