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

iOS Swift 2.0 Collections and Control Flow Dictionaries Working with Dictionaries

Swift 2.0

Challenge Task 3 of 4

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.

no work again Bummmm

dictionary.swift
// Enter your code below

// Enter your code below

var iceCream = ["CC": "Chocolate Chip",
                "AP": "Apple Pie",
                "PB": "Peanut Butter"]

                iceCream["RR"] = "Rocky Road"

 let iceCream = [AP] = "Apple Pie"

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Hmmm ... you didn't name your constant according to the code challenge, additionally, the value from the dictionary needs to be retrieved via bracket notation.

Here's a correct way of doing it.

let applePie = iceCream["AP"]

Hope it helps.