Method: Kernel#Array
- Defined in:
- object.c
#Array(object) ⇒ Object
Returns an array converted from object
.
Tries to convert object
to an array using to_ary
first and to_a
second:
Array([0, 1, 2]) # => [0, 1, 2]
Array({foo: 0, bar: 1}) # => [[:foo, 0], [:bar, 1]]
Array(0..4) # => [0, 1, 2, 3, 4]
Returns object
in an array, [object]
, if object
cannot be converted:
Array(:foo) # => [:foo]
3875 3876 3877 3878 3879 |
# File 'object.c', line 3875
static VALUE
rb_f_array(VALUE obj, VALUE arg)
{
return rb_Array(arg);
}
|