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]
3900 3901 3902 3903 3904 |
# File 'object.c', line 3900 static VALUE rb_f_array(VALUE obj, VALUE arg) { return rb_Array(arg); } |