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 trial
Lyric Abbott
35,595 Pointshelp
Modify the create_shopping_list method to return a hash with the following keys and values: 'title': A string with the value "Grocery List" 'items': An empty array http://teamtreehouse.com/library/ruby-collections/build-a-grocery-list-program/method-returns-with-hashes-and-arrays
my code:
def create_shopping_list
hash = { "Grocery List" => title, => items }
return hash
end
2 Answers
Maciej Czuchnowski
36,441 PointsYou got the keys and values switched and you don't have an empty array, which is signified by opening and closing square brackets. It should be:
{'title' => "Grocery List", 'items' => []}
Also, remember that the method by default returns the last thing done in the method, so you can remove the hash = and return hash parts.
ellie adam
26,377 Pointsdef create_shopping_list
hash = {'title' => "Grocery List", 'items' => []} end
Javier Pacheco
3,418 PointsJavier Pacheco
3,418 PointsThis whole hash and array has confused me. Any other resources to get further explanation?