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 Swift 2.0 Functions Function Parameters Returning Complex Values

Adi Firdaus
Adi Firdaus
3,528 Points

Hi, I already create the code, and test that's the code is works on playground but i cannot pass the challenge

herewith the code :

func getTowerCoordinates(location : String)->(Double, Double){
    //var lat:Double
    //var lon:Double

    let latlon:(Double, Double)

    switch location{
    case "Eiffel Tower":
        //lat =  48.8582
        //lon = 2.2945
        latlon =  (48.8582, 2.2945)
    case "Great Pyramid":
       // lat =  29.9792
       // lon = 31.1344
        latlon =  (29.9792, 31.1344)
    case "Sydney Opera House":
        //lat =  33.8582
        //lon = 151.2140
        latlon =  (33.8582, 151.2140)
    default:
        //lat = 0
        //lon = 0
        latlon =  (0,0)
    }

    return latlon
}

getTowerCoordinates("Eiffel Tower")
functions.swift
// Enter your code below

func getTowerCoordinates(location : String)->(Double, Double){
    //var lat:Double
    //var lon:Double
   // var latlon = (Double, Double)

    switch location{
    case "Eiffel Tower":
        //lat =  48.8582
        //lon = 2.2945
        latlon =  (48.8582, 2.2945)
        //return (48.8582, 2.2945)
    case "Great Pyramid":
       // lat =  29.9792
       // lon = 31.1344
        latlon =  (29.9792, 31.1344)
        //return (29.9792, 31.1344)
    case "Sydney Opera House":
        //lat =  33.8582
        //lon = 151.2140
        latlon =  (33.8582, 151.2140)
        //return (33.8582, 151.2140)
    default:
        //lat = 0
        //lon = 0
        latlon = (0,0)
        //return (0,0)
    }

    //return latlon
    }

2 Answers

Ghaith Ali
Ghaith Ali
3,134 Points

Hmmmm, maybe the problem is that you are making your defining latlon as a constant and then you are assigning it a value, which is not allowed since its a constant. Try to define latLon as a variable and see if it works:)

Adi Firdaus
Adi Firdaus
3,528 Points

Hi Gaith Ali,

Thank you very much for your reply : "I Cannot pass the Challenge because i put the wrong value for the "LAT" on "Sidney Opera House" : on my answer is : Lat = 33.8582 ==== should be 33.8587

and herewith the working solution.

func getTowerCoordinatest(location : String)->(Double, Double){ let latlon:(Double, Double)

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

return latlon

}

getTowerCoordinatest("Eiffel Tower")