hashmap in ruby code example
Example 1: ruby map hash
hash = { bacon: "protein", apple: "fruit" }
hash.map { |k,v| [k, v.to_sym] }.to_h
# {:bacon=>:protein, :apple=>:fruit}
Example 2: ruby assign value to hash
grades = Hash.new
grades["Dorothy Doe"] = 9
Example 3: how to access hash value ruby
my_hash["key"] #=> "value"