How can I assign multiple values to a hash key?

后端 未结 4 618
没有蜡笔的小新
没有蜡笔的小新 2020-12-30 13:55

For the sake of convenience I am trying to assign multiple values to a hash key in Ruby. Here\'s the code so far

myhash = { :name => [\"Tom\" , \"Dick\" ,         


        
4条回答
  •  梦毁少年i
    2020-12-30 14:33

    You've created a hash with the symbol name as the key and an array with three elements as the value, so you'll need to iterate through myhash[:name] to get the individual array elements.

提交回复
热议问题