Answers for "ruby map hash"

3

ruby map array

array = ["a", "b", "c"]
array.map { |string| string.upcase }
# ["A", "B", "C"]
Posted by: Guest on May-16-2020
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

Browse Popular Code Answers by Language