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 Basics (retired) Collections What is a Dictionary?

Need an Example

The quiz asks me to assign a constant to a key value, the video does not do this specifically. with the info provided i want to do this: let ukCurrency = ("UK") Please show me an example. I feel these quizzes are more focus on me asking questions than the actual content.

dictionaries.swift
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = ("UK")

1 Answer

David Galindo
PLUS
David Galindo
Courses Plus Student 2,294 Points

Hello Daniel so the code I think you need is the following

let ukCurrency = currencies["UK"]

so with this line of code we are creating a constant named ukCurrency and we assign a key Value. All we need to do is call up your dictionary and the Key ("UK"). with this we get the value "Pound" assign to your constant. Hope this helps !!