Issue #17472 has been updated by jeremyevans0 (Jeremy Evans).


I am against adding this in principle.  One of the harder things for new Ruby programmers to understand is the difference between symbols and strings.  This is even more difficult for programmers learning Ruby and Rails at the same time, due to the fact that Rails treats symbols and strings the same in most places.

I'm also against adding this for the reasons that @Eregon mentioned. If a speed-up is desired, `HashWithIndifferentAccess` can easily be a C-extension gem, there is no pressing reason to have it in core or stdlib.

If we do decide to add this to Ruby, it should have a better name. `HashWithIndifferentAccess` is not indifferent in regards to type (`1` and `"1"` are different).  `HashWithIndifferentAccess` is not indifferent in regards to case (`"a"` and `"A"` are different).  `HashWithIndifferentAccess` is not indifferent in regards to encoding, at least some of the time (`"\u1234"` and `"\u1234".b` are different).  "WithIndifferentAccess" is too vague.  `HashCovertingSymbolKeysToStringKeys` is more accurate, though quite long.

----------------------------------------
Feature #17472: HashWithIndifferentAccess like Hash extension
https://bugs.ruby-lang.org/issues/17472#change-89578

* 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.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>