Ruby’s Array#push appends one or more objects to the end of an array. Starting with [1, 2, 3, 4], a.push(5) produces [1, 2, 3, 4, 5]. section 9.2.2
Related operations clarify when push is the better fit:
- Use << to append one object with infix syntax; unlike push, it does not take multiple arguments here. section 9.2.2
- Pair push with unshift, pop, and shift when manipulating array ends. section 9.2.2
Appending a batch
a = [1, 2, 3, 4, 5] a.push(6, 7, 8) # a is now [1, 2, 3, 4, 5, 6, 7, 8]



