Method: Range#last
- Defined in:
- range.c
#last ⇒ Object #last(n) ⇒ Array
Returns the last object in the range, or an array of the last n elements.
Note that with no arguments last will return the object that defines the end of the range even if #exclude_end? is true.
(10..20).last #=> 20
(10...20).last #=> 20
(10..20).last(3) #=> [18, 19, 20]
(10...20).last(3) #=> [17, 18, 19]
897 898 899 900 901 902 |
# File 'range.c', line 897
static VALUE
range_last(int argc, VALUE *argv, VALUE range)
{
if (argc == 0) return RANGE_END(range);
return rb_ary_last(argc, argv, rb_Array(range));
}
|