clonecq clonecq - 1 month ago 8
Ruby Question

about creating hash with certain keys

I am lost. I need to create a hash with keys corresponding to numbers from 1 to 10. The result should be something like this:

my_hash = {1 => "", 2 => "", 3 => ""...}


I have

h = Hash.new


please give me at least one way of doing that, I will need "values" later, for now I just need a hash with keys and I will push values later. Thanks!

Answer
h = Hash.new
(1..10).each {|count| h[count] = ''}