1

Thank you for the help in advance! I'd like to add or push a value into my array which is currently within a person hash and task hash.

Look below at the add task section 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}"}

You simply had an error there. I removed the parenthesis to make it maybe a little more obvious.

于 2013-06-25T21:43:03.450 回答