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 trial

iOS Swift Basics (retired) Collections What is a Dictionary?

cannot pass 2nd part of question because dictionary is immutable

i can't pass the second part and the error is something about it being immutable. let ukCurrency = currencies.removeValueForKey("UK") thats my second part of the code and i can't create this constant because of currencies already being a constant. it won't let me remove the value since it is a constant. help please?

2 Answers

Damien Watson
Damien Watson
27,419 Points

Once you have defined the currency then you can create a constant from it:

let currencies = ["US":"Dollar", "UK":"Pound", "JP":"Yen"];
let ukCurrency = currencies["UK"];

Thanks a lot brotha i was lost

Damien Watson
Damien Watson
27,419 Points

No problems, glad to help.