Re:Ruby 3.1.0 Preview 1
by mostlysimilar on Tuesday November 09, 2021 @11:36AM
(#29163910)
It's only two keystrokes if your parameters are single characters.
vs
[ Parent
| on HN ]
Is it to spare keystrokes in method definition, or rather, in method invocation?
Your second definition reads that `with_longer_parameters` is a keyword argument with no default.
Still, you've illustrated the keystroke savings with your choice of parameter names :-)
Yeah, should be invocation, there's a nice example on the feature request (https://bugs.ruby-lang.org/issues/14579):
def login(username: ENV["USER"], password:)
p(username:, password:)
end
login(password: "xxx") #=> {:username=>"shugo", :password=>"xxx"}