Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Collections Build a Grocery List Program Working with Hashes That Contain Arrays

Unable to solve Ruby Collections - Working with Hashes that contain Arrays - code challenge

Unable to solve the following code challenge which asks to add the grocery_item hash to the 'items' array within the grocery_list hash. However constantly saying unexpected curly brace.

''' grocery_list = { 'title' => 'Grocery List', 'items' => [{"grocery_item"}] } grocery_item = { 'title' => 'Bread', 'quantity' => 1 } '''

1 Answer

Claudiu Bancos
.a{fill-rule:evenodd;}techdegree seal-36
Claudiu Bancos
Front End Web Development Techdegree Graduate 22,468 Points

Basically, you're calling the array named "items" inside of the hash named "grocery_list", and then pushing "grocery_item" (which happens to be a hash) into that array. I think that's the way the teacher intended for us to solve it.

Thank you Claudiu for your help! Your code worked perfect and I understand what I was doing wrong.