method
values_at
ruby latest stable - Class:
Array
values_at(*args)public
Returns an array containing the elements in self corresponding to the given selector(s).
The selectors may be either integer indices or ranges.
See also Array#select.
a = %w{ a b c d e f } a.values_at (1, 3, 5) # => ["b", "d", "f"] a.values_at (1, 3, 5, 7) # => ["b", "d", "f", nil] a.values_at (-1, -2, -2, -7) # => ["f", "e", "e", nil] a.values_at (4..6, 3...6) # => ["e", "f", nil, "d", "e", "f"]
static VALUE
rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
{
return rb_get_values_at(ary, RARRAY_LEN(ary), argc, argv, rb_ary_entry);
}