Hacker News new | ask | show | jobs
by cpb 1679 days ago
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 :-)

1 comments

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"}