Skip to content
class method

Array.[]

[U] (*U) -> ::Array[U]
[](*args)

Returns a new array, populated with the given objects:

Example
Array[1, 'a', /^A/]    # => [1, "a", /^A/]
Array[]                # => []
Array.[](1, 'a', /^A/) # => [1, "a", /^A/]

Related: see Methods for Creating an Array.

See also #[] #[]= .new .try_convert also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0