0034 Numbered_parameters

Numbered parameters

Ruby 2.7 introduces numbered parameters in blocks. There are 9 of them, and they are reserved exclusively for blocks (the experimental version was with @!).


With Ruby 3.4, there will also be it to complement _1. But there are a few restrictions. You can’t mix numbered, it and named parameters. There can only be one level of numbered parameters.


Please note that arrays will be automatically decomposed if this is the only parameter and if a numbered parameter greater than or equal to 2 is used. For example, with Hash.


Link to Ruby documentation for numbered parameters.