Ruby Ruby Collections Ruby Hashes Working with Hash Values

Andrew Ackerman
Andrew Ackerman
8,347 Points

Having difficulty with Task 2 of Working with Hash Values.

So I'm passing Task 1 with no difficulty. But overtime I add to the cods for Task 2 it tells me that Task 1 no longer passes. The only way I can get that to still pass is if I remove the "grocery_list" name for Array but then I still fail Task 2 because I don't have the correct name. I would love some guidance on this please!

grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }
if grocery_item.has_value?("Bread")"food", true)


  grocery_item.values_at("item" =>

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,430 Points

OK, so you should not have to modify any code from Task 1 to make Task 2 work.

You want to create a new variable. we do it like this:

grocery_list = <some value>

we need to replace <some value> with what they are asking us - which is calling values_at method on the grocery_item hash, with "item" as the argument. Please watch the video again and check the teacher's notes under the video. All the answers are here: