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 trialRastislav König
812 PointsHello. I'm stuck at the switch statement chalenge and I would need some help to solve it.
Here is the link to the chalenge - https://teamtreehouse.com/library/swift-collections-and-control-flow/control-flow-with-conditional-statements/working-with-switch-statements .
Rastislav König
812 PointsI'm getting stuck at the the switch statement.... I'm not sure if know hoe to use properly. I can send u screenshot if that could help.
1 Answer
Zimri Leijen
11,835 Pointsswitch (condition)
case "a": // in other words if condition == a
// action a (for example europeanCapitals.append(value)
case "b":
// action b
default:
// fallback action when neither of the cases match
you could use key
as your condition
and append the value to the right array.
You'll have to make some kind of lookup table for which city belongs to which continent.
Rastislav König
812 PointsIm not sure how to make an lookup table or what do u mean by that, Im learning swift for a short time
Zimri Leijen
11,835 PointsZimri Leijen
11,835 PointsWhat have you tried so far, where are you getting stuck?