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!

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 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.