Feature #19328
closedPlease bring back the use of Hash objects for keyword arguments
Description
The change in 3.0 (linked here https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/) no longer automatically converts Hash objects into keyword arguments. This takes Ruby away from what it has always been about: being as intuitive and developer friendly as possible.
The solution given to make a hash into keywords is to perform a double splat (**) on the hash object. This is confusing and esoteric, not to mention will require a lot of old code to be re-written.
For example I have code that was written like this
def Foo(a:, b:)
puts a + b
end
which I can call by simply using
myhash = {a:3, b:5}
Foo(myhash)
Look at the clarity, simplicity and convenience. The interpreter takes care of the messy and unnecessary bits and our code is easily understandable by other humans.
But now for the same function we need to write
Foo(**myhash)
We have to add superficial extra strokes (from the human perspective) to achieve what our intelligent interpreter once knew we wanted with less hassle.
Let's not become like those other language! Please keep Ruby intuitive, convenient and developer friendly and make this feature what is was before.
Updated by randallcoding (Randall Coding) over 2 years ago
- Description updated (diff)
Updated by jeremyevans0 (Jeremy Evans) over 2 years ago
Considering:
- That separating keyword and positional arguments was done for good reasons (as explained in the
"Why we're deprecating the automatic conversion" section of the page you linked to), - That reverting the change would reintroduce all of the previous problems that Ruby 2 keyword arguments had,
- That the separation happened 3 released versions ago and is now well established, and
- That the vast majority of gems have upgraded to support keyword argument separation,
I estimate that this feature request has a 0% change of approval.
Updated by randallcoding (Randall Coding) over 2 years ago
jeremyevans0 (Jeremy Evans) wrote in #note-2:
is now well established
Many developers are working on legacy systems that aren't immediately up to date with the latest version of ruby. To imply this is "established" across the entire community is misleading. I didn't have a single client using rails 3.0 or greater until this week.
for good reasons
I don't think the edge case given is good reason to remove commonly used and well made Ruby functionality. It is not worth the trade off. I suggest handling the edge case specifically and retain the original quality of the previous feature.
I estimate that this feature request has a 0% change of approval.
I want to make my voice heard regardless of the likelihood of a change. And also, it is never too late to correct a mistake.
Updated by Eregon (Benoit Daloze) over 2 years ago
- Status changed from Open to Rejected
This would mean breaking code working on 3.0/3.1/3.2, of course that's not acceptable.
Adding **
there is not a big deal and it makes a lot of sense once you understand keyword arguments are now separated from positional arguments.