Answers for "ruby hash"

0

ruby map hash

hash = { bacon: "protein", apple: "fruit" }

hash.map { |k,v| [k, v.to_sym] }.to_h
# {:bacon=>:protein, :apple=>:fruit}
Posted by: Guest on August-26-2020
0

ruby assign value to hash

grades = Hash.new
grades["Dorothy Doe"] = 9
Posted by: Guest on June-24-2020

Browse Popular Code Answers by Language