1

事前に助けてくれてありがとう!現在個人ハッシュとタスク ハッシュ内にある配列に値を追加またはプッシュしたいと考えています。

以下のタスクの追加セクションを見てください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
4

1 に答える 1

0
task.merge! "person1" => {:high => "#{new_task}"}

あなたは単にそこにエラーがありました。もう少しわかりやすくするために、括弧を削除しました。

于 2013-06-25T21:43:03.450 に答える