Ruby Ruby Collections Ruby Hashes Working with Hash Values

What am I suppose to do?

How can I add new item?

hash.rb
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }

if grocery_item.has_value?("Bread")
  grocery_item{"food" => true}
end

1 Answer

Michael Hess
Michael Hess
24,499 Points

Hey Ufuk,

It looks like you're really close, but try this:

grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }

# task 1
if grocery_item.has_value?("Bread")
  #use comma instead and use .store
   grocery_item.store("food", true)
end

Hope this helps!

There is a problem with mobile app I guess. I'll try with my computer later. Thanks for helping?