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?

Is this a bug?

I am trying to complete Task 2 on the Dictionaries Section but i don't now what is the matter with this code:

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

let ukCurrency = currencies

ukCurrency["UK"]

I xcode everything seems fine.

Is this a bug?

dictionaries.swift
let currencies   = ["US" : "Dollar", "UK" : "Pound", "JP" : "Yen"]

let ukCurrency = currencies

ukCurrency["UK"]

2 Answers

Your code runs, it's just not accomplishing the outcome that the challenge wants. They want you to put the just value of the UK currency inside the constant ukCurrency. You're putting the whole dictionary (all the currencies) into ukCurrency. Try this:

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

let ukCurrency = currencies["UK"]

Thank you ! That was the point :-)