ruby get valeu from hash
To get a specific value from a hash you can use the following methods:
hash = {:key1 => "value1", 'key2' => "value2"}
Getting by a symbol:
hash[:key1]
or
Getting by a string:
hash['key2']
or
Getting by string or symbol:
Obs.: HashWithIndifferentAccess is part of rails active_support gem so this option only works on a Rails project or using the active_support gem:
hash = HashWithIndifferentAccess.new({:key1 => "value1", :key2 => "value2"})
hash[:key1] # "value1"
hash['key1'] # "value1"