Topic: how to add elements to ruby array (solved)

is there a way to add more than one element to a ruby array?  i can do it for hashes with the "merge" function but am not able to find something similar for arrays.

for example, if sample = [1, 2]

then i can do
sample << 3
sample << 4
sample << 5

is there a way to add 3, 4, 5 to sample with one command?

Last edited by sthapit (2008-09-11 07:34:55)

Re: how to add elements to ruby array (solved)

sample.push(3, 4, 5)

# or

sample << 3 << 4 << 5


Both work.

Rob Anderton
TheWebFellas

Re: how to add elements to ruby array (solved)

awesome, thanks!