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 trialDaniel Lambrecht
iOS Development Techdegree Student 5,302 Pointsive spent like 45 mins and im still lost... ive also tried to use "BEL ": Brussels": europeanCapitals.append(value)
ive also tried to use "BEL ": Brussels": europeanCapitals.append(value) and all sorts of thing, cant get it to work
var europeanCapitals: [String] = []
var asianCapitals: [String] = []
var otherCapitals: [String] = []
let world = [
"BEL": "Brussels",
"LIE": "Vaduz",
"BGR": "Sofia",
"USA": "Washington D.C.",
"MEX": "Mexico City",
"BRA": "Brasilia",
"IND": "New Delhi",
"VNM": "Hanoi"]
for (key, value) in world {
// Enter your code below
switch (key, value) {
case "BEL", "LIE", "BGR": europeanCapitals.append(value)
case "USA", "MEX", "BRA": otherCapitals.append(value)
case "IND", "VNM": asianCapitals.append(value)
}
// End code
}
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Daniel,
You are on the right track, but there are a couple of things:
First, in the switch statement, you are switching on key, value
but are only providing a single case
value. This is why the compiler is complaining. In this case, it's 'switching' on a String, String
but only being given a String
. You only need to switch
on the key, not both.
Second, it seems that you may have misunderstood the instructions that state
for the default case, append the values to otherCapitals.
Right now, your switch statement
does not have a default clause. So, you should delete your second case
and at the end put in a default statement for the others (instead of hard-coding as you have in the second case
).
Give it another go with these in mind. I'm sure you'll get it now, but if you're still stuck, post a comment here.
Another hint/tip. When you are doing the coding in the challenges, if there is a preview button, click it. It will give the errors that the checker is encountering and from there you should be able to debug what is wrong.
Keep Coding! And Good Job!
:)
Daniel Lambrecht
iOS Development Techdegree Student 5,302 PointsDaniel Lambrecht
iOS Development Techdegree Student 5,302 PointsThat did it!
Thanks so much : )