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 trialWilliam Crawford
4,319 PointsSwift CollectionsnStg 4,Chg 2of2-Dictionary
I got part one. My question is, how can you change the value of a constant? let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"] currencies["UK"] = "uKCurrency" gives a mutability error, and so does: let uKCurrency = currencies.updateValue("uKCurrency", forKey: "UK") The challenge says to define "uKCurrency", which I thought I did? I may move on, and come back. Help appreciated.
4 Answers
Logan R
22,989 PointsGood tries, but all you need to do to assign a variable a key is to do:
Array["key"]
So in this case:
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies["UK"]
William Crawford
4,319 PointsThanks, Logan. I think I had tried that before. I tried it now, and get the reply:
Bummer! You need have let ukCurrency
defined.
Logan R
22,989 PointsWhat is your code? The second block of code I have works, as I have tested it.
William Crawford
4,319 Pointslet currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"] let uKCurrency = currencies ["UK"]
Logan R
22,989 PointsIt's ukCurrency, not uKCurrency. The program is case sensitive :)
Also, I accidently pressed best answer, lol, sorry. I unchecked it.
William Crawford
4,319 PointsOoooooh. Thanks, Logan. I swear I saw uKCurrency. I was typing it on purpose - wrong. Thanks for the help!!
Logan R
22,989 PointsNo problem :) If you have any more questions, feel free to post them on the forums!