by mostlysimilar · 5y ago · 0 comments
def some_method(with_longer_parameters: with_longer_parameters)
do_something(with_longer_parameters)
end
vs def some_method(with_longer_parameters:)
do_something(with_longer_parameters)
endYour 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 :-)
def login(username: ENV["USER"], password:)
p(username:, password:)
end
login(password: "xxx") #=> {:username=>"shugo", :password=>"xxx"}