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 trial

iOS Functions in Swift Adding Power to Functions Returning Complex Values

I don't know know what they mean by return types. Please help. Thank you in advance! John

I need help on this one.

Thank you for your time!

John

functions.swift
// Enter your code below
func coordinates(for location: String) -> (lat: Double, lon: Double) {

switch location {
case "Eiffel Tower": (48.8582, 2.2945)
case "Grate Pyramid": (29.9792, 31.1344)
case "Sydney Opera House": (33.8587, 151.2140)
default: (0,0)

}

return ()

}

coordinates("Eiffel Tower")

2 Answers

Jonathan Ruiz
Jonathan Ruiz
2,998 Points

Hi John you are close on this one. There is a few things to change in the code, the first is the spelling for "Great Pyramid" don't worry as you code spelling errors is what causes errors at times. You don't have to put names for the parameters in the tuples. For switch statements you are switching on the correct item in this case location. However for the cases after you write out the string and put : you then put return and then in this case the tuple you want to return.

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)
    }
}

Hope that helps keep it up !

Thanks very much Jonathan!

Yours was the correct answer.

Have a great day!!!

Jonathan Ruiz
Jonathan Ruiz
2,998 Points

Glad it worked out happy to help ! I always recommend doing the code challenges in the browser. Then having Xcode on the side with the code as well. Often times Xcode can show you errors in real time.