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?

am I not understanding the question correctly

help

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

let ukCurrency = ["UK": "Pound"]

2 Answers

The task is to retrieve a value from the existing Dictionary (which you created in the previous step) using the key "UK". Right now, you're making a new Dictionary, not reading a value via a key from the existing Dictionary.

In the end, ukCurrency will hold the string "Pound".

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

let ukCurrency = currencies.removeValueForKey("UK")

I've got this and it's not working for me. Not sure why, exactly. Any help would be much appreciated.

They really just want let ukCurrency = currencies["UK"].

Instead of removing the value given the key, they want you to retrieve it, which is done using the special syntax I used above.

Simply the task was to capture the value of the key "UK". Thank you for the enlightenment. I sometimes make things more complicated than what they should be. Thanks again!!!

Gracias!