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 trialSapho Maqhwazima
805 PointsHi guys, I have tried everything, please clarify and assist here, thanks.
func getTowerCoordinates (location: String) -> (Double, Double) { switch location { case "Eiffel Tower": return (48.8582, 2.2945) case "Great Pyramid": return (29.9792, 31.1344) case "Sydney Opera House": return (33.8587, 151.2140) default: return (0,0) } }
// Enter your code below
func getTowerCoordinates (location: String) -> (Double, Double) {
switch location {
case "Eiffel Tower": return (48.8582, 2.2945)
case "Great Pyramid": return (29.9792, 31.1344)
case "Sydney Opera House": return (33.8587, 151.2140)
default: return (0,0)
}
}
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHi Sapho,
You've got the correct syntax, but you did not follow the instructions of the task correctly. Instructions are very strict, and everything must be exactly as asked or the challenge will receive the Bummer!
.
Here, there are two things. The instructions say:
Declare a function named coordinates that takes a single parameter of type String, with an external name for, a local name of location, and returns a tuple containing two Double values
So, you are missing the "external name" of for
for the parameter, and the function is not named correctly... it should be named coordinates
.
Once you fix up those two things, the challenge will pass.
Keep Coding! :)
Mitch Little
11,870 PointsHi Sapho,
You have just made a few simple mistakes.
Firstly, the challenge asks you to create a function name coordinates not getTowerCoordinates. This should look like this:
func coordinates(for location: String)
You have then forgotten to add an external name ' for' which should be added just before the local name of 'location':
func coordinates(for location: String) -> (Double, Double) {
Your switch statement however is spot on, well done!
Overall the solution to this challenge should look like this:
func coordinates(for location: String) -> (Double, Double) {
switch location {
case "Eiffel Tower": return (48.8582, 2.2945)
case "Great Pyramid": return (29.9792, 31.1344)
case "Sydney Opera House": return (33.8587, 151.2140)
default: return (0,0)
}
}
In Xcode, your solution would work, however it isn't the solution the challenge was looking for. Perhaps go over parameter labels again.
All the best,
Mitch