hash map ruby code example
Example 1: how to access hash value ruby
my_hash.values_at("key1", "key2") #=> ["value1", "value2"]
Example 2: ruby map hash
hash = { bacon: "protein", apple: "fruit" }
hash.map { |k,v| [k, v.to_sym] }.to_h
# {:bacon=>:protein, :apple=>:fruit}
Example 3: how to access hash value ruby
my_hash["key"] #=> "value"