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 trialAndriy Yezerskiy
1,808 PointsHello It came to my attention that this exercise is broken, as you cannot removeValueForKey from a constant.
// it has to be:
var currencies = [ "US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies.removeValueForKey("UK")
var currencies = [ "US": "Dollar",
"UK": "Pound",
"JP": "Yen"]
5 Answers
Steve Hunter
57,712 PointsHi,
Apologies for my previous answer - I hadn't read the code challenge!!
I don't think you're removing anything from the constant called currencies
. You create the dictionary, then assign the value of currencies["UK"]
to a constant called ukCurrency
. There's no removing of anything from the immutable dictionary.
Steve.
Andriy Yezerskiy
1,808 PointsYes i am aware of that, I just found a solution to this problem. Instead of removing value which can't be done when dictionary is a constant. You can add value by doing this:
let currencies = [ "US": "Dollar", "UK": "Pound", "JP": "Yen" ] let ukCurrency = currencies["UK"]
Then the question can be completed :) But thanks for your help
Andriy Yezerskiy
1,808 PointsThanks for your quick reply :)
Steve Hunter
57,712 PointsExactly, yes. The question didn't want to remove anything from the dictionary; just assign a value from it to a constant.
Hope you're enjoying the course!
Steve.
Andriy Yezerskiy
1,808 PointsThanks a lot for your help :) I sure will.
Andriy
Steve Hunter
57,712 PointsSteve Hunter
57,712 Points