In Ruby 3, the new ...
syntax was introduced, allowing constructs like these:
def locked_run(...)
lock
run(...)
unlock
end
This is documented here: https://rubyreferences.github.io/rubychanges/3.0.html
After this discussion (https://bugs.ruby-lang.org/issues/16378), it was decided to let positional arguments in as well:
def block_section(name, ...)
section(name, true, ...)
end
However, the following still leads to a syntax error:
def block_section(...)
section(block_section: true, ...)
end
Why are positional arguments allowed with ...
but named arguments are not?
This wouldn't be the correct syntax anyway. Looking at how Ruby does things, it expects named arguments (i.e., hash) to be the last arguments after the normal ones.
So what you would need is this:
However, this still doesn't work, as it hasn't been implemented as part of the Ruby language grammar for the new
...
currently.If you want this, I'd suggest creating an issue (or emailing or something else) to request it.