Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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")
  grocery_item.store("food", true)


  grocery_item.values_at("item" => grocery_list.new)

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 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: https://teamtreehouse.com/library/ruby-collections/ruby-hashes/working-with-hash-values