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 trialchristine picone
4,510 Pointsruby hashes challenge: task 1 no longer passing
I'm not sure what is going wrong here. I passed task 1, then I get an error message. Does anyone know what could be wrong?
Thanks!
#GIVEN
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }
#Task 1
grocery_item.has_value?("Bread")
if grocery_item.has_value?("Bread") == true
grocery_item.store("food", true)
end
#Task 2
grocery_list = [ grocery_item.values_at?("item") ]
2 Answers
Salman Akram
Courses Plus Student 40,065 PointsHi Christine,
You need to remove square brackets [ ] around the last output. Then all is good.
#GIVEN
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company" }
#Task 1
grocery_item.has_value?("Bread")
if grocery_item.has_value?("Bread") == true
grocery_item.store("food", true)
end
#Task 2
grocery_list = grocery_item.values_at("item")
christine picone
4,510 PointsThanks Salman! I wish it wasn't so buggy where I thought that something was wrong with the first task's code. It was driving me crazy!
c