4 ms·
Hah, I had to try this out to believe it. You can do `foo d: {:y => 2}` or `foo :d => {:y => 2}` but not a raw hash literal without parens. That's parse.y[1]
by cronin101 11y ago
Hah, I had to try this out to believe it.
You can do `foo d: {:y => 2}` or `foo :d => {:y => 2}` but not a raw hash literal without parens.
That's parse.y[1] for you...
[1]: https://github.com/ruby/ruby/blob/trunk/parse.y https://github.com/ruby/ruby/blob/trunk/parse.y
- tomphoolery 11y agoIt's because Ruby thinks {} is a block. All Ruby methods can implicitly take a block (why? who knows...), so the single-line block syntax is parsed as such before it can be considered a hash argument into the method.