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 trialzeyad kholban
1,272 PointsAssign the value for key in dictionary
if i define currencies as constant i can't change it, but with var currencies it's working in the playground
var currencies = ["US" : "Dollar", "UK" : "Pound", "JP" : "Yen" ]
let ukCurrency = currencies.removeValueForKey("UK")
Dennis Parussini
Treehouse Project ReviewerWhat exactly don't you understand about this?
Adam Shockley
2,767 PointsWhen you declare currencies as a constant you are explicitly telling the program that you don't want its values to be modified. That's why you can't call removeValueForKey() unless currencies is declared as a variable.
I misunderstood your problem before.
1 Answer
Dennis Parussini
Treehouse Project ReviewerTook me a while but now I see what's wrong. ;-)
In this challenge you don't need to use .removeValueForKey(). You only have to assign the value of the currency to a new constant.
So, your code should look like this:
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies["UK"]
If you need further help I'd be glad to help.
Adam Shockley
2,767 PointsAdam Shockley
2,767 PointsYour code is compiling fine for me.