Ruby block and unparenthesized arguments

It’s because you’re calling

pp x.map

and passing a block to pp (which ignores it)

As explained in the Programming Ruby book

Braces have a high precedence; do has a low precedence

So, effectively, braces tie to the function call closest to them (x.map) whereas do binds to the furthest away (pp). That’s a bit simplistic but it should explain this situation

Leave a Comment