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?

Anish Nuni
Anish Nuni
765 Points

How do you assign the value of a key to a constant?

Please help me assign key UK to constant ukCurrency

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

let ukCurrency = 

2 Answers

Mikael Enarsson
Mikael Enarsson
7,056 Points

You would use the string identifier:

let currencies = ["US":"Dollar" , "UK":"Pound" , "JP":"Yen"]
let ukCurrency = currencies["UK"]
Anish Nuni
Anish Nuni
765 Points

Thanks Mikael. The video didn't explain it well and I had been trying for a while, so that is why I turned to the forums. Thanks again!

Mikael Enarsson
Mikael Enarsson
7,056 Points

No problem ^^ It's useful for me too, it makes me really think about what I know XD

Emmanuel Ouzan
Emmanuel Ouzan
4,107 Points

Hi Anish Nuni,

I recommend you next time you have a question about the quizzes that you should go back to the last video you have watched and there you will find the answer to the quiz.

It will save you some expensive time ! :)

Good luck,

Emmanuel.