|
|
|
|
|
by fiedzia
998 days ago
|
|
> # you would have to be a psychopath to pass this
> # anything but a User object
> def grant_admin_privileges(user:) I had an app once where we used user objects, and later switched to ids to save db calls. Now you have some functions that can accept both, and some that accept one of them, and without type hints (that was long time ago) you can easily make a mistake. |
|
Ruby has had keyword arguments since Ruby 2.0 from 2008 and earlier code could certainly use option hashes.
So I don't see a reason for any confusion there.
In the second example, you would really have to be asleep at the wheel to make a mistake like: I don't see the problem. It would be nice if a compiler/IDE could catch that, but on the other hand, it just looks blatantly wrong as you type it and will certainly blow up the first time you call it.