instance method
Kernel#Array
(nil) -> [ ]
[T] (::array[T] | ::_ToA[T] array_like) -> ::Array[T]
[T] (T ele) -> [ T ]
Array(object) → object or new_array
object.c
View on GitHub ↗
static VALUE
rb_f_array(VALUE obj, VALUE arg)
{
return rb_Array(arg);
}
Returns an array converted from object.
Tries to convert object to an array using to_ary first and to_a second:
Example
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:
Example
Array(:foo) # => [:foo]