Why is pushing a hash into an array in Ruby had to use parenthesis?
I would like to add a hash into an array using Ruby version 1.8.7:

    items = Array.new
    items.push {:a => "b", :c => "d"}

Statements above will return an error something like:

    SyntaxError: compile error
    (irb):35: syntax error, unexpected tASSOC, expecting '}'
    items.push {:a => "b", :c => "d"}
                     ^
    (irb):35: syntax error, unexpected ',', expecting '}'
    items.push {:a => "b", :b => "c"}
                          ^

Well, I found that the solution is to wrap the push arguments within parenthesis `( )` or I can use the `<<` operator. I also know that `push` accept one or more argument and `<<` only accept a single argument from [this answer][1], but what's bothering me is that ***why do I need to use the parenthesis, while as we all know parenthesis in Ruby are optional?***


  [1]: http://stackoverflow.com/a/10569543/155640
Why is pushing a hash into an array in Ruby had to use parenthesis?
===

I would like to add a hash into an array using Ruby version 1.8.7:

    items = Array.new
    items.push {:a => "b", :c => "d"}

Statements above will return an error something like:

    SyntaxError: compile error
    (irb):35: syntax error, unexpected tASSOC, expecting '}'
    items.push {:a => "b", :c => "d"}
                     ^
    (irb):35: syntax error, unexpected ',', expecting '}'
    items.push {:a => "b", :b => "c"}
                          ^

Well, I found that the solution is to wrap the push arguments within parenthesis `( )` or I can use the `<<` operator. I also know that `push` accept one or more argument and `<<` only accept a single argument from [this answer][1], but what's bothering me is that ***why do I need to use the parenthesis, while as we all know parenthesis in Ruby are optional?***


  [1]: http://stackoverflow.com/a/10569543/155640