From: hcatlin@... Date: 2021-01-17T12:57:51+00:00 Subject: [ruby-core:102122] [Ruby master Feature#17472] HashWithIndifferentAccess like Hash extension Issue #17472 has been updated by hcatlin (Hampton Catlin). During my 15 years of Ruby programming, I can't remember a single time that the difference between string-and-symbol with regards to Hashes was used on purpose. Instead, it's the source of countless bugs, extra typechecking code, and difficulty when you install a new library��� ("hmmm, is this options hash going to be stringed or symboled?") The argument that SINCE it trips up beginners, that's a good thing, as they get to learn an important lesson about... design flaws in Ruby? That's such an odd argument to me! In almost every use of Hash in my career, the keys have being either symbols or strings, and I can't think of production code that even uses the fact that you can use an object as a key as a feature. I think I've attempted it myself a couple times, but usually refactored the code after, berating myself for trying to be a little too clever. Which brings me to #11882 ! I opened this proposal 5 years ago that would basically mean that Rails wouldn't *need* HashWithIndifferentAccess, as Ruby would have it's own stringed, symbol-or-string agnostic Map implementation. In the last year I've come back to full time Ruby programming, and this remains one of my biggest frustrations with the language. Hash was cute when I first learned the language and it was an early differentiator, but other languages have improved this paradigm and I think we should too! ---------------------------------------- Feature #17472: HashWithIndifferentAccess like Hash extension https://bugs.ruby-lang.org/issues/17472#change-89978 * Author: naruse (Yui NARUSE) * Status: Open * Priority: Normal * Target version: 3.1 ---------------------------------------- Rails has [ActiveSupport::HashWithIndifferentAccess](https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html), which is widely used in Rails to handle Request, Session, ActionView's form construction, ActiveRecord's DB communication, and so on. It receives String or Symbol and normalize them to fetch the value. But it is implemented with Ruby. If we provide C implementation of that, Rails will gain the performance improvement. summary of previous discussion: https://github.com/rails/rails/pull/40182#issuecomment-687607812 -- https://bugs.ruby-lang.org/ Unsubscribe: