From: yoelblumenator@... Date: 2021-03-27T00:31:03+00:00 Subject: [ruby-core:103046] [Ruby master Feature#17472] HashWithIndifferentAccess like Hash extension Issue #17472 has been updated by joelb (Joel Blum). > I think the critical use case for HashWithIndifferentAccess is params; where you want to be using symbol keys because it's cleaner syntax, but the keys are coming from untrusted input We can agree the vast majority of Ruby devs are web programmers, mostly with Rails. So they also write a lot of javascript and obviously they prefer the js syntax {name: 'joe'} to rocket {'name' => 'joe'}, so they mostly use symbols **under the hood** (emphasized because the developer 99% of the time doesn't care whether it's a symbol or a string during normal, routine web/Rails work. The developer simply wants a dictionary with string like keys and prefers to use the js object notation). So if 99% of the time you don't care whether it's a symbol or a string, yet the popular hash syntax goes for symbol keys, what happens is every time you do JSON.parse you will get stringified keys and it's very easy to see why from a user point a view some indifferent construct makes sense. The truth is most of us ARE indifferent, we just want a dictionary with string like names. ---------------------------------------- Feature #17472: HashWithIndifferentAccess like Hash extension https://bugs.ruby-lang.org/issues/17472#change-91107 * 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: