public Method

Kernel.Array(p1)

Array(arg)     array

Returns arg as an Array. First tries to call arg.to_ary, then arg.to_a. If both fail, creates a single element array containing arg (unless arg is nil).

Array(1..5)   #=> [1, 2, 3, 4, 5]

Source Code

/*
*  call-seq:
*     Array(arg)    => array
*  
*  Returns <i>arg</i> as an <code>Array</code>. First tries to call
*  <i>arg</i><code>.to_ary</code>, then <i>arg</i><code>.to_a</code>.
*  If both fail, creates a single element array containing <i>arg</i>
*  (unless <i>arg</i> is <code>nil</code>).
*     
*     Array(1..5)   #=> [1, 2, 3, 4, 5]
*/

static VALUE
rb_f_array(obj, arg)
   VALUE obj, arg;
{
   return rb_Array(arg);
}
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.