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 trialAustin Schau
2,819 PointsHelp with dictionary challenge
What am i doing wrong with this code? I can get this code to work in Xcode, but not here. Help please!!
Challenge: Assign the value for key "UK" to a constant named ukCurrency.
Compiler Text: swift_lint.swift:5:18: error: immutable value of type '[String : String]' only has mutating members named 'removeValueForKey' let ukCurrency = currencies.removeValueForKey ("UK")
let currencies = ["US":"Dollar", "UK":"Pound","JP":"Yen"]
let ukCurrency = currencies.removeValueForKey ("UK")
5 Answers
Kenneth Giorno
4,043 PointsAlright, so the key here is in the compiler error text you get. I'm not entirely certain, because I'm just learning swift, but with some experience in searching error logs, I'd say the swift:_lint.swift:5:18: error: immutable value of type '[String : String]' only has mutating members... translates to
error output: swift line 5 (let ukCurrency = currencies...) character 18 (c in currencies) throws the error... then the first word it says is immutable. we're trying to adjust currencies by calling removeValueForKey on it, but for some reason, perhaps in the code above, currencies can not be changed (or is immutable).
Matthew Jobraal
429 PointsI'm having the same problem...Help!
Kenneth Giorno
4,043 PointsDid you check your code for why currencies is immutable/unchangeable?
José Yánez
Courses Plus Student 432 PointsHow can I d this exercise???
José Yánez
Courses Plus Student 432 PointsHow can I d this exercise???
Matthew Jobraal
429 PointsI'm new to this, but what if you try the following: var currencies = ["US":"Dollar", "UK":"Pound","JP":"Yen"] let ukCurrency = currencies.removeValueForKey ("UK")