Ruby Method of the Day - Array.+

Posted by Kelly McCauley on Oct 24, 2007

Signature

array + other_array   #=> new_array

array + other_array returns new_array that contains the concatenation of array and other_array.

Examples

1
2
[1,2,3,4,5] + [5,6,7,8,9]   #=> [1, 2, 3, 4, 5, 5, 6, 7, 8, 9]
[5,6,7,8,9] + [1,2,3,4,5]   #=> [5, 6, 7, 8, 9, 1, 2, 3, 4, 5]

Documentation Reference

Ruby version 1.8.6

www.ruby-doc.org : Array.+