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 trialAnthony Smith
2,738 PointsSingle Value Array Issue
When I attempt the 2nd task of the challenge (creating a single value array) I seem to undo the task for the first challenge. How is adding an array undoing it if I am not touching the code? Sometimes I can modify it to where it then tells me that my value is not found in the array.
grocery_item = { "item" => "Bread", "quantity" => 1, "brand" => "Treehouse Bread Company", "food" => true }
grocery_item.has_value?("Bread")
grocery_list = ["grocery_item.values_at("item")"]
1 Answer
Matt Buckingham
11,389 PointsOnly item should be in quotes! So it should look like this
grocery_list = [grocery_item.values_at("item")]
Kepa Tairua
Courses Plus Student 4,404 PointsKepa Tairua
Courses Plus Student 4,404 PointsJust in addition to the above, your code:
grocery_list = ["grocery_item.values_at("item")"]
is basically saying: grocery_list is an array with one string, and that string is "grocery_item.values_at("
After that, Ruby gets confused because you haven't added a comma or closed square brace when it was expecting one after your string.