clonecq clonecq - 11 months ago 47
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 =

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 Source
h =
(1..10).each {|count| h[count] = ''}