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?

lochie westfall
lochie westfall
2,568 Points

this is impossible , you cant change a constant

what do i do to advance?

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

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Lochie,

This task has caught quite a number of users off guard because of the previous video, one thing most users miss is Amit actually shows us how to assign values to a variable/constant using an dictionary in the video prior to the challenge.

Here is the question for task two:

Assign the value for key "UK" to a constant named ukCurrency.

So as I mentioned Amit does show us how to retrieve values from an dictionary using a key, we do this by using the square brackets and passing a string which in this case is UK.

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

Happy coding!