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?

Nik Parekh
Nik Parekh
598 Points

Can I please get some help with the second question

How do I remove and add "UK" to ukCurrency

2 Answers

Holt Hunter
Holt Hunter
4,629 Points

Here is your dictionary:

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

To access an item in a dictionary you use the key instead of the position, for example:

println(currencies["UK"])

This would print "Pound", because it is located at the "UK" index. So to assign "Pound" to ukCurrency you would need to do this:

let ukCurrency = currencies["UK"]

That assigns "Pound" to ukCurrency which is what the quiz wanted you to do.