Numbered Parameters to Blocks in Ruby
Ruby blocks offer a shorthand to positional block variables.
Normally you'd see a block like this:
[1, 2, 3].each { |number| do_something(number) }
However with Numbered Parameters, introduced in Ruby 2.7, we can express this like so:
[1, 2, 3].each { do_something(_1) }
The _1
takes the place of an explicitly defined block variable.