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 trialBrant Faulkner
7,921 Points[solved] Build a Grocery List Program challenge.
I am stuck on this challenge, any tips on where I am going wrong would be appreciated.
I have also noticed that through these Ruby challenges the instructors use of single vs double quotes appears random much of the time. My current understanding is that one should use double quotes when the string needs to be interpolated.
But I am not sure when we should be using single quotes, or no quotes. Any guidance on that would be awesome too.
def create_shopping_list
hash = { 'title' = "Grocery List", 'items' => Array.new}
return hash
end
Geoff Parsons
11,679 PointsBrant Faulkner I added "[solved]" to your title since Ryan Trimble's suggestion should solve the issue you're having. Next time post your response as an answer Ryan so we can give you some points for it! :)
Brant Faulkner
7,921 PointsThanks Ryan. That was it.
Funny how a typo can create doubt in my understanding of the material. Will keep that in mind going forward.
1 Answer
J.D. Sandifer
18,813 PointsReposting the solution above as an answer so it doesn't show up as unanswered:
To assign a value to a key in a hash, you need to use the => symbol. You have it on your "Items" key, but the "title" key only has an = symbol.
Ryan Trimble
15,559 PointsRyan Trimble
15,559 PointsHi there Brant,
To assign a value to a key in a hash, you need to use the => symbol. You have it on your "Items" key, but the "title" key only has an = symbol.
should be:
Looks OK otherwise!
As for the single vs. double quotes question, you seem to have an understanding for it. Double quotes are used when an variable needs to be interpolated.