Created
October 15, 2012 13:01
-
-
Save lucasdavila/3892347 to your computer and use it in GitHub Desktop.
Merge itself with simbolized keys in rails
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
hash = {'a' => 1, 'b' => 2} | |
# => {"a"=>1, "b"=>2} | |
hash.merge hash.symbolize_keys | |
# => {"a"=>1, "b"=>2, :a=>1, :b=>2} | |
hash.to_json | |
# => "{\"a\":1,\"b\":2}" | |
hash[:a] = 3 | |
hash["b"] = 4 | |
hash | |
# => {"a"=>1, "b"=>4, :a=>3, :b=>2} | |
hash.to_json | |
# => "{\"a\":3,\"b\":2}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment