Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Array#concat

(*::Array[Elem] arrays) -> self
concat(*other_arrays) → self

Adds to self all elements from each array in other_arrays; returns self:

Example
a = [0, 1]
a.concat(['two', 'three'], [:four, :five], a)
# => [0, 1, "two", "three", :four, :five, 0, 1]

Related: see Methods for Assigning.

See also #compact! #count #compact #cycle also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0