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 trialAJ Vazquez
1,064 PointsHow do I finish this without failing miserably
HOW
// Enter your code below
func coordinates(for location: String) -> (Double, Double) {
let coordinates = ["Eiffel Tower", "Great Pyramid", "Sydney Opera House"]
for coordinate in coordinates
switch { coordinate
case "Eiffel Tower":print(lat:48.8582, lon:2.2945)
case "Great Pyramid":print(lat:29.9792, lon:32.1344
case "Sydney Opera House":print(lat:33.8587, lon:151.2140)
default (0,0)
}
}
2 Answers
Jhoan Arango
14,575 PointsHey JR,
Few things, it's very important to read the instructions carefully, try to solve them step by step. I see in your code, things that the challenge did not included, and this may confuse you.
Basically we are creating a function that will return a tuple, remember that when returning a tuple, is very important to return the amount of values in the tuple, in this case we want to return 2 doubles. Some tuples may have more than 2 values and they may even be different types.
You are going to switch the parameter location, and do each case as a "String" with the names of each location provided to you by the challenge. They must be strings, because that is the parameter's type.
Then since we did not named the labels in the tuples, then we do not use the "lat: 00.000, 00.000", we only use the "Doubles".
// Enter your code below
func coordinates(for location: String) -> (Double, Double) {
switch location {
case "Eiffel Tower": // String
return (48.8582, 2.2945) // Return a tuple with Doubles without the names
case "Great Pyramid":
return (29.9792, 31.1344)
case "Sydney Opera House" :
return (33.8587, 151.2140)
default:
return (0,0)
}
}
If you have any more questions, please tag me.
Good luck
AJ Vazquez
1,064 PointsThank you I just was stressed a little because so much was happening at the time. Also this pic <------ Is not my face I'm just on my dads account, we're getting it changed soon.
Jhoan Arango
14,575 PointsNo Problem,
Trust me it happens to all of us. To this day I run into code that I myself have a hard time understanding. But it's part of the process.
Keep it up.
Good luck
AJ Vazquez
1,064 PointsAJ Vazquez
1,064 PointsI just don't know what the compiler is saying