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 trialKAJAL SRIVASTAVA
4,549 PointsDictonary assignment
In part of dictonary task "Assign the value for key "UK" to a constant named ukCurrency."
either I am not getting the what you mean with question or missing very basic thing.
Can you please provide the solution.
2 Answers
Chris Shaw
26,676 PointsHi Kajal,
There's plenty of solutions on the forum for this specific question which is a bit vague if you're new to Swift and programming in general, so let's break it down.
- Define a constant called
ukCurrency
- From the
currencies
dictionary select the<key:value>
pair for UK
Still confusing?
Let's remember back to dictionary basics, for each <key:value>
pair we have we can access the value using the key we've specified, for example.
let myDict = ["key1": "value1", "key2": "value2"]
println(myDict["key2"]) // results in "value2" being printed to the console
So let's apply that to the challenge, if we've done everything correctly we should end up with the following.
let ukCurrency = currencies["UK"]
// ukCurrency = Pound
Hope that helps.
KAJAL SRIVASTAVA
4,549 Pointsthanks Chris. It worked. I was assigning in last part in vice versa.
emerson mcintyre
1,024 Pointsemerson mcintyre
1,024 PointsThanks Chris, I was stuck on this too!