ruby: Syntax for implicit block arguments
In a ruby block (or proc) you can implicitly refer to unnamed positional arguments with the special syntax \_1
, \_2
etc.
[1,2,3].map { _1 + 1 }
Since ruby 3.4 you can implicitly refer to a single unnamed position argument with the special syntax it
:
[1,2,3].map { it + 1 }
Published on: 27 May 2025