public Method

Array.values_at(...)

array.values_at(selector,... )   an_array

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)
a.values_at(1, 3, 5, 7)
a.values_at(-1, -3, -5, -7)
a.values_at(1..3, 2...5)

Source Code

/* 
*  call-seq:
*     array.values_at(selector,... )  -> an_array
*
*  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 <code>Array#select</code>.
* 
*     a = %w{ a b c d e f }
*     a.values_at(1, 3, 5)
*     a.values_at(1, 3, 5, 7)
*     a.values_at(-1, -3, -5, -7)
*     a.values_at(1..3, 2...5)
*/

static VALUE
rb_ary_values_at(argc, argv, ary)
   int argc;
   VALUE *argv;
   VALUE ary;
{
   return rb_values_at(ary, RARRAY(ary)->len, argc, argv, rb_ary_entry);
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.