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 trialNick Riddell
1,594 PointsI am stuck on the has_value? method challenge. The error message states that the has_value? method was not called.
I am new to coding and at a loss as to where I have gone wrong.
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }
grocery_item.has_value?("Bread")
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company", "food" => true }
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Nick,
You're on the right track, and have checked the has_value()
correctly, but the challenge wants you to add the food = true
to the hash, whereas you have re-declared the entire hash.
Your second line of code should be
grocery_item["food"] = true
To review how to add key/values to a ruby hash, Jason covers this back in the first video of this section.
Keep Coding! :)