Skip to main content
Ask A Question
Notifications
You’re not receiving notifications from this thread.
Subscribe

Is there a good reason to not use keyword arguments always?

General • Asked by Rutul Dave

I have used keyword arguments for some of my methods before, but haven't really thought about why not use it for all methods with arguments?

Seems like there is no good reason to have the caller ever know the correct ordering for the arguments.

If verbosity of the code is the only issue with keyword arguments, is there a good reason to not use keyword arguments for all your methods?

More on keyword arguments from Thoughtbot - https://robots.thoughtbot.com/ruby-2-keyword-arguments


I think its mostly just not taken off due to habit. We've had position arguments and then optional hashes which are pretty much keyword arguments so it's not a big change, but it's definitely a nice one.

It's probably a good habit to start using them where they make sense from now on. I'll probably just keep forgetting to do it though. :)


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.