What is the difference between #concat and += on Arrays?
arrays, concatenation, ruby
Solution
`+=` would create a new array object, `concat` mutates the original object
a = [1,2]
a.object_id # => 19388760
a += [1]
a.object_id # => 18971360
b = [1,2]
b.object_id # => 18937180
b.concat [1]
b.object_id # => 18937180
Note the `object_id` for `a` changed while for `b` did not change
Problem
I want to concatenate two Arrays in Ruby. So far I have found the `#concat` and the `+=` operator. They seem to produce the same result, but I want to know what is the difference between them. - Where can I find the documentation for the `+=` operator? - What are the differences between `#concat` and using the `+=` operator on Arrays?