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

Brian Hogue
Brian Hogue
2,482 Points

Bug on Working with Hash Values Challenge Task 2 of 2

https://teamtreehouse.com/library/ruby-collections/ruby-hashes/working-with-hash-values-2

This challenge will not let me pass, though I am providing good code. I tested the code using my own .rb file and running it in Terminal. When I ask it to "puts grocery_list", it returns Bread, proving that the code is getting the correct value and is placing it in the new array. But Treehouse tells me the new array does not include "Bread." Please see the attached screenshot. Forgive me if I'm wrong, but to my logic, the code I have written is doing exactly what was asked in the challenge.

here are my screenshots http://imgur.com/a/S4MIb

2 Answers

Hi Brian,

As I can see your screenshot, one minor error is square bracket [ ], that is not necessary to have it. Values_at method would create new hash automatically.

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

Hope that helps.

Brian Hogue
Brian Hogue
2,482 Points

Thank you. It's maddening that it was something so simple, but thank you.