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

NAVEED CHOWDHURY
NAVEED CHOWDHURY
1,142 Points

Code Challenge Geographical Coordinates

I am kind of stuck here, can anyone explain me what am I doing wrong here, Thanks in advance.

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

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

}
Xavier D
Xavier D
Courses Plus Student 5,840 Points

Hey Naveed,

Perhaps one or two things...

...one...removing that forward slash right before your function definition should get your code to compile and run correctly...

...two...perhaps removing the labels in your return parameter list? I've noticed that sometimes putting in stuff that is not required may produce errors in the challenges...

3 Answers

Xavier D
PLUS
Xavier D
Courses Plus Student 5,840 Points

Hey Naveed,

Perhaps one or two things...

...one...removing that forward slash right before your function definition should get your code to compile and run correctly...

...two...perhaps removing the labels in your return parameter list? I've noticed that sometimes putting in stuff that is not required may produce errors in the challenges...

Jeff McDivitt
Jeff McDivitt
23,970 Points

There are two error in your code

  1. The task does not ask you to return lat and long, you do not need it in your return method
  2. In Sydney Opera House you mis spelled house
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)
    }
}
NAVEED CHOWDHURY
NAVEED CHOWDHURY
1,142 Points

Thanks a lot everyone, much appreciated.