Regarding hash key and value mapping

I couldn't get the hash value well, so I looked it up and found that it was a bit overlooked.

hash1 = {key: "value"} #=> {:key=> "value"}

When,

hash2 = {"key"=> "value"} #=> {"key"=> "value"}

Did not understand the difference. It seems that the key name changes depending on how you write it. In the above example

hash1["key"] #=> nil
hash1[:key] #=> "value"

become.

Recommended Posts

Regarding hash key and value mapping
[Ruby] I want to extract only the value of the hash and only the key
ConcurrentHashMap does not allow nulls for key and value
[ruby] How to assign a value to a hash by referring to the value and key of another hash
hash and each statement
Terraform: (and Ansible: and Chef :) Extract a hash from an array where a key has a specific value.