Created
August 9, 2012 17:56
-
-
Save localshred/3306542 to your computer and use it in GitHub Desktop.
Symbolize keys doesn't do what I expected when to_sym equivalent keys exist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fascinating behavior of symbolize_keys usage. If you have two keys that | |
# are `to_sym` equivalents, the non-symbol version is the winner, | |
# regardless of the order in the hash. | |
# For some reason I expected if a symbol key existed it would be | |
# the winner. | |
1.9.2p290 :002 > {"one" => 1, :one => 2}.symbolize_keys | |
=> {:one=>1} | |
1.9.2p290 :001 > {:one => 1, "one" => 2}.symbolize_keys | |
=> {:one=>2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment