Didn't watch the video, but what I find interesting is that keyword arguments did not exist until Ruby 2.0, which means before Ruby 2.0, there's a totally different way to do hack it, and you'll sometimes see this in the wild :) (I've encountered this in Rails' DateTime library)


# Ruby 2.0
def method(first:, second:)
  puts "First: #{first}, Second: #{second}"
end

# Ruby 1.9
def method(options={})
  first = options.fetch(:first)
  second = options.fetch(:second)
  puts "First: #{first}, Second: #{second}"
end

robots.thoughtbot.com/ruby-2-keywo...

 
 

Seems right as shown, but perhaps only for .new?

For any other method:

  • If the parameters are related, could they form a class and be passed as an object?

  • If not, does the method lack a unified purpose?

 

Right, better params no more than 3. If more than 3 maybe should use hash or object.

 

How does it handle extra arguments? Does it ignore it or throw an exception?

 
Classic DEV Post from Oct 19 '18

Have you used the new "suggested changes" in GitHub pull requests?

These are pretty cool! "Suggested Changes" are in public beta and allow you to ...

Ruby, and learn Rust, Go, Elixir, Erlang...

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️