How to add to an existing hash in Ruby

前端 未结 7 1615
悲哀的现实
悲哀的现实 2021-01-30 00:02

In regards to adding an key => value pair to an existing populated hash in Ruby, I\'m in the process of working through Apress\' Beginning Ruby and have just fi

7条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-30 00:22

    x = {:ca => "Canada", :us => "United States"}
    x[:de] = "Germany"
    p x
    

提交回复
热议问题