Skip to content
instance method

Array#replace

(::Array[Elem]) -> self
replace(other_array) → self

Alias of #initialize_copy

Replaces the elements of self with the elements of other_array, which must be an array-convertible object; returns self:

Example
a = ['a', 'b', 'c']   # => ["a", "b", "c"]
a.replace(['d', 'e']) # => ["d", "e"]

Related: see Methods for Assigning.