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?

Stage 4 challenge 2

This is the answer to the first question let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"] and the second part asks me to modify the key "UK" to "ukCurrency". How do I do that? I thought let won't allow you to change anything. I typed var currencies also but it asked me to use let.

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

1 Answer

Ethan Lowry
PLUS
Ethan Lowry
Courses Plus Student 7,323 Points

Hi, are you sure it doesn't just want you to use the different key name when creating the dictionary? As in, don't add a new line, just modify the one you have?

So this is exactly how it says on the second part. Assign the value for key "UK" to a constant named ukCurrency.

Maybe I am still confused with something. Could you please help me? the video used var instead of let and I think I am missing something.

Ethan Lowry
Ethan Lowry
Courses Plus Student 7,323 Points

Oh ok, that's different then, ignore my original answer.

What it wants you to do is create a constant called ukCurrency, which you already know how to do, using let. And you want to assign that constant the value from your dictionary with the key of "UK". The video lessons show you how to access values out of a dictionary, so if you forgot how to do this, you should go back and watch it again, then it should be simple.