I did small performance test of Ruby\'s array concat()
vs +
operation and concat()
was way too fast.
I however am not clear on why
According to the Ruby docs, the difference is:
Array#+ :
Concatenation — Returns a new array built by concatenating the two arrays together to produce a third array.
Array#concat :
Array#concat : Appends the elements of other_ary to self.
So the +
operator will create a new array each time it is called (which is expensive), while concat
only appends the new element.