Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Jacob Tucker
512 Pointswhy doesnt the following statement work let ukCurrency = currencies.removeValueForKey ("UK")
assuming first line is correct which it is
1 Answer

Stone Preston
42,016 Pointsyou misinterpreted what the task is asking you to do.
task 2 states: Assign the value for key "UK" to a constant named ukCurrency.
you dont remove the value assigned to the key "UK", you assign the value of that key to a new constant, whilst keeping the dictionary the same (you dont want to remove any keys/values or anything like that)
the swift eBook states:
You access and modify a dictionary through its methods and properties, or by using subscript syntax
subscript syntax consists of the name of the dictionary followed by a pair of square brackets with the key inside:
someDictionary["someKey"]
the above code returns the value for the key "someKey" in the dictionary named someDictionary
so to assign the value for the key "UK" to a constant named ukCurrency you would use
let currencies = [ "US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies["UK"] // ukCurrency now has a value of "Pound"