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

Bug in dictionary

let currencies = ["US":"Dollar","UK":"Pound","JP":"Yen"] How can i assign the value for a key "UK" to a constant name ukcurrency .......

5 Answers

Yes, that was a hint. Just put the key where I have What Goes Here. You have to use the KEY to get the VALUE in return

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

It really works man thanks a lot for your help ....... I appreciate it. Alot thanks

Do you mean something like:

        let usCurrency = "Dollar"
        let ukCurrency = "British Pound"
        let jpCurrency = "Yen"
        let currencies = ["US": usCurrency , "UK": ukCurrency, "JP" : jpCurrency ]

The bummer says you must have 'let curreny ' defined

Oh, you are doing a challenge. I thought you were trying to write different code as a matter of practice. Which challenge is that? It is not listed that you are asking a question for a particular challenge.

Sorry about that. I found your challenge. You just need to do the assignment.

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

let ukCurrency = currencies[WHAT GOES HERE?]

Yup you are right thats problem ...., do you know solution ...

Sorry for that i am beginner and its my first time that i post a question in treehouse forum ....so got little out of way ... So its the challenge of dictionary in swift basics ........can you help me ........ First step was to make a dictionary with constant name currency and to insert key and its value as a country and currency simultaneously ..... First step answer is this let currencies = ["US":"Dollar","UK":"Pound","JP":"Yen"] and in next it was asking me to assign the value for a key "UK" to a constant name currency ...... Whenever i try change the value it everytimes ask me to defined let ukcurrency ....