提前感谢您的帮助! 我想在我的数组中添加或推送一个值,该数组目前位于人员哈希和任务哈希中。
请参阅下面的添加任务部分task.merge!
task = {
"person1" => {
:high => ["email", "phone","email2","talk","meeting"],
:mid => ["task1","task2"],
:low => ["task1","task2"] },
"person2" => {
:high => ["email", "phone","email2","talk","meeting"],
:mid => ["task1","task2"],
:low => ["task1","task2"] },
"person3" => {
:high => ["email", "phone","email2","talk","meeting"],
:mid => ["task1","task2"],
:low => ["task1","task2"] },
}
puts task["person1"][:high][0]
# create task
#create new person hash within task hash
#already have :high, :mid, & :low hash
# add task
#add a task to the array within either high,mid, or low
task.merge!("person1" => {:high => "#{new_task}")
# remove task
#delete method
答案 0 :(得分:0)
task.merge! "person1" => {:high => "#{new_task}"}
那里你只是犯了一个错误。我删除了括号,使它可能更明显一些。