Ruby allows the shovel operator to push multiple things into an Array in one line.

>> arry = []
=> []
>> arry << :a << :b << :c
=> [:a, :b, :c]

:)

2 thoughts on “Ruby Tips #178 – Push Many Things into Arrays in One Line

  1. Stephan says:

    pst ->
    the array is actually [:a, :b, :c], with c becoming a symbol.

  2. BrettU says:

    Thanks Stephan. I updated the typo.

Leave a Reply

Your email address will not be published. Required fields are marked *