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
Stuck in Dictionaries
I'm stuck in the test part of dictionaries. I rewatched the videos and had notes to help me remember the lecture, but i cant seem to get the answer here although i followed what the professor told me to do.
"Let's pretend a customer has ordered an ice cream. Retrieve the value for apple pie using the correct key and assign it to a constant named applePie."
Thanks in advance! :)
// Enter your code below var iceCream = ["CC": "Chocolate Chip", "AP": "Apple Pie", "PB": "Peanut Butter"] iceCream.updateValue("Rocky Road", forKey: "RR") iceCream["AP"] let applePie = iceCream["AP"]
Hi Ronie, I dont think youre as "stuck" as you think you are. You made it to part 3 of the challenge! good job!
Everything is right with you code except where you inserted iceCream["AP"] above the applePie constant. Was there a reason you added this?
Stuart Wright41,117 Points
You just need to delete:
Your next line is correct.
The line that you're deleting would be fine in Playground if you just want to see what the value of iceCream["AP"] is, but you would never use it in a real program, and it's what causes the following error in the code challenge:
swift_lint.swift:23:9: error: expression resolves to an unused l-value iceCream["AP"] ~~~~~~~~^~~~~~