Method: Kernel#Array

Defined in:
object.c

#Array(arg) ⇒ Array

Returns arg as an Array.

First tries to call to_ary on arg, then to_a. If arg does not respond to to_ary or to_a, returns an Array of length 1 containing arg.

If to_ary or to_a returns something other than an Array, raises a TypeError.

Array(["a", "b"])  #=> ["a", "b"]
Array(1..5)        #=> [1, 2, 3, 4, 5]
Array(key: :value) #=> [[:key, :value]]
Array(nil)         #=> []
Array(1)           #=> [1]

Returns:



3954
3955
3956
3957
3958
# File 'object.c', line 3954

static VALUE
rb_f_array(VALUE obj, VALUE arg)
{
    return rb_Array(arg);
}