Ruby Ruby Collections Build a Grocery List Program Working with Hashes That Contain Arrays

Can somebody tell me what's going wrong?

Plz tell me where am i making a mistake ?

shopping_list.rb
grocery_list = { 'title' => 'Grocery List', 'items' => [] }
grocery_item = { 'title' => 'Bread', 'quantity' => 1 }

puts grocery_list['item'].push(grocery_item)

1 Answer

Rogier Nitschelm
Rogier Nitschelm
iOS Development Techdegree Student 5,460 Points

The key in the grocery_list-hash is named items rather than item.

grocery_list['items'].push(grocery_item)
# or
grocery_list['items'] << grocery_item