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?

Eli Oaks
Eli Oaks
243 Points

What exactly is wrong with my code?

I'm not exactly sure what I'm doing wrong. I defined the dictionary "currencies" correctly, but I keep getting a compiling error whenever I try to define the constant "ukCurrency" with the value of the key "UK". I've rechecked that section of the video, but I'm still not sure. If you could help, that'd be great.

Just to clarify, I do NOT want someone to just give me the code. I really just want a nudge in the right direction as well as what I'm doing wrong. I want to learn this material myself, and not just have it handed to me.

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

2 Answers

Hi Eli,

Check your method - are you being expected to remove the key/value pair from the dictionary? Or just assign a value to a variable based on a particular key?

Steve.

It's saying to create a constant named ukCurrency under the key "UK". Your provided code removes it the "UK" value in Currencies.

This code challenge has two tasks. The first is to create the dictionary called currencies. The the second task says:

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

I am sure that there are other code challenges that require a key/value pair to be removed but that isn't this one.