I recently ran into an oddity while looking at some Ruby code from the Rails docs.
Ruby lets you pass arguments like these examples:
redirect_to post_url(@post), alert: "Watch it, mister!"
redirect_to({ action: 'atom' }, alert: "Something serious happened")
But that second case looked odd to me. It seems like you should be able to pass it like so:
redirect_to { action: 'atom' }, alert: "Something serious happened"
And it would have the same meaning with or without parenthesis. But instead you get:
syntax error, unexpected ':', expecting '}'
Referring to the colon after action
. I'm not sure why it would be expecting }
there, and why using parenthesis would change that.