From: naruse@... Date: 2020-12-28T03:41:58+00:00 Subject: [ruby-core:101767] [Ruby master Feature#17472] HashWithIndifferentAccess like Hash extension Issue #17472 has been updated by naruse (Yui NARUSE). My intention is * A feature to implement Rails's ActiveSupport::HashWithIndifferentAccess, not providing HashWithIndifferentAccess itself. * the key of internal hash should be symbol though ActiveSupport::HashWithIndifferentAccess uses String as key. * rails doesn't depend C extension. I added a link to kamipo's summary as more context https://github.com/rails/rails/pull/40182#issuecomment-687607812 Dan0042 (Daniel DeLorme) wrote in #note-6: > I'm also against this, but I think a more general-purpose version might be ok. In my code I use a `NormalizedHash` class which calls `key = normalize(key)` for every method with a `key` argument (as well as `merge`, etc.) I use this base class to define subclasses with specific `normalize` methods; `HeaderHash` converts keys to Http-Header-Camelcase, `OptionsHash` raises an error if the key is not a Symbol. Something that can be used as the basis of different implementations (including `HashWithIndifferentAccess`) might make sense in the stdlib. Might. You can use Hash#compare_by_identity (https://ruby-doc.org/core-2.7.1/Hash.html#method-i-compare_by_identity). ---------------------------------------- Feature #17472: HashWithIndifferentAccess like Hash extension https://bugs.ruby-lang.org/issues/17472#change-89595 * 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: