iOS Functions in Swift Adding Power to Functions Returning Complex Values

Ruben Mercado
Ruben Mercado
1,933 Points

don't know

don't know what to return

// Enter your code below
func coordinates(for location: String) -> (Double, Double){
switch location{
case "Eiffel Tower" : print(48.8582, 2.2945)
case "Great Pyramid": print(29.9792, 31.1344)
case "Sydney Opera House" :  print(33.8587, 151.2140)
default: print(0,0)

return location



2 Answers

Jason Anders
Jason Anders
Treehouse Moderator 145,038 Points

Hi Ruben,

You are on the right track :thumbsup: but have a look at the instructions again. Instructions are very specific in what they ask and must be followed exactly.

Your syntax is all correct, but not what the challenge instructions ask for.
First, the final return you have (return location) is not need, nor is it asked for. The instructions do explicitly say that each case (including the default) should return "a tuple containing two Double values", but you are attempting to print them instead.

If you delete that final return statement and fix up the code to match the instructions (return instead of print) the challenge will pass.

Other than that... Great job!! :)

Keep Coding! :dizzy:

Binh Tri
Binh Tri
1,920 Points

Hi Ruben, From what I know, you could create 2 variables named lat and lon in the function. Then in each case, you assign the values for lat and lon. Ex: case "Eiffel Tower": lat = 48.8582; lon = 2.2945. For default case just assign 0. The return syntax should be outside of the curly braces of switch command. Then you should return both lat and lon in the end. Hope it helps!