Append items to an array
Today I came across yet another way to add items to an array in ruby
I already knew about push
and <<
, but did you know that there's also an append
?
[1,2,3].push(4)
# => [1,2,3,4]
[1,2,3] << 4
# => [1,2,3,4]
[1,2,3].append(4)
# => [1,2,3,4]
append
is ultimately just an alias for push
, but always good to know!