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

Zachary Ehren
Zachary Ehren
5,786 Points

Stuck on coding challenge

I'm working on Task 2 of the Working with Hash Values challenge which asks for this:

"Using the values_at method, create an array called grocery_list with the value of the grocery_item hash at the "item" key."

I wrote out the code that's attached but when I submit, I'm getting the following response:

"Oops! It looks like Task 1 is no longer passing."

The code it's referring to is on lines 3 & 4.

I'm guessing there is something wrong with line 6 in my code because I've checked and rechecked lines 3 & 4 and they appear to be good. Can someone point me in the right direction?

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

grocery_item.has_value? ("Bread")
grocery_item ["food"] = true

grocery_list = [grocery_item.values_at ("item")]

1 Answer

Zachary Ehren
Zachary Ehren
5,786 Points

Never mind! I figured out the issue. I had an extra space in line 6. Once I changed it to grocery_list = [grocery_item.values_at("item")], it worked.