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 trialRikki Ringgold
11,565 PointsI think I'm missing something but I can't figure it out.
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...
Do I need to add an external name "for"? If so where and how?
// Enter your code below
func coordinates(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)
}
}
coordinates(location:"Great Pyramids")
1 Answer
andren
28,558 PointsDo I need to add an external name "for"? If so where and how?
You do indeed, external parameter names was explained in the Argument Labels video that came earlier in this section.
A short summary is that an external parameter name is one that comes before the local name, so you literally just have two names for the parameter separated by a space. The first name is the external one, which is used when passing a value into the function. The second name is the local name, which is used within the function itself.
It looks like this:
func coordinates(for location: String) -> (Double, Double) { // <-- I added "for" before the "location" name
}
Also now that you have changed the external name to for
you need to change the label you use when you call the function at your last line, though since calling the function is not something the challenge asks you to do you can also just remove that line entirely.
Rikki Ringgold
11,565 PointsRikki Ringgold
11,565 PointsHaha thanks! I swear I tried that multiple times and it just was not taking my answer. I thought I was going crazy.
Thank you for the prompt response and help.