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 @!).

0034-numbered_parameters_1.png

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.

0034-numbered_parameters_2.png

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.

0034-numbered_parameters_3.png

Link to Ruby documentation for numbered parameters.