Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default IndifferentHash keys to Symbols instead of Strings #1593

Closed
wants to merge 3 commits into from

Conversation

baelter
Copy link
Contributor

@baelter baelter commented Feb 13, 2020

.. so it works with keyword args works as expected.

Fixes #1592

@dentarg
Copy link
Member

dentarg commented Feb 15, 2020

I guess the docs need to be updated?

# Internally, symbols are mapped to strings when used as keys in the entire
# writing interface (calling e.g. <tt>[]=</tt>, <tt>merge</tt>). This mapping
# belongs to the public interface. For example, given:

@baelter
Copy link
Contributor Author

baelter commented Feb 18, 2020

Perhaps "You are guaranteed that the key is returned as a string" should be changed to "You are guaranteed that the key is returned as a symbol" for consistency? But I figured that's more of a breaking change.

@dentarg
Copy link
Member

dentarg commented Feb 18, 2020

Sounds like a breaking change to me :)

Is there any performance gain/regression happening with this change?

I wonder what our maintainers (@jkowens @namusyaka @olleolleolle and probably others) think of this change?

@jkowens
Copy link
Member

jkowens commented Mar 10, 2020

This issue has also been brought up in the Rails project. Since this models ActiveSupport::HashWithIndifferentAccess I would like to stay in line with the approach there. I'm wondering if we can also provide a method symbolize_keys that will serve as a work around.

See:

rails/rails#14643

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

https://til.hashrocket.com/posts/d66e55091c-hashwithindifferentaccess-for-keyword-arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

params can't be used as keyword arguments
3 participants