iOS Functions in Swift Adding Power to Functions Returning Complex Values

Jesse Gay
STAFF
Jesse Gay
Treehouse Staff

What am I missing? Code works in Xcode but won't pass.

Does anyone know why this isn't passing? I looked at other solutions, and one of them seems identical to mine, but I can't get this one to pass. It works in Xcode.

Also, why is (0,0) acceptable for the default return case (per the instructions)? Doesn't the function need to return a Tuple of Doubles?

functions.swift
// Enter your code below
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 "Syney Opera House":
        return(33.8587, 151.2140)

    default:
        return(0,0)
    }
}

2 Answers

Jennifer Nordell
MOD
Jennifer Nordell
Treehouse Moderator

Hi there! Nope, this will not create an error in Xcode. Check very closely your spelling of "Sydney Opera House". You've accidentally typed "Syney" instead of "Sydney". You missed a "d" in there. Other than that, you're doing terrific!

Hope this helps! :sparkles:

edited for additional information

I could be mistaken here, but I believe there's an implicit conversion from Int to Double in that default. :smiley:

Michael Hulet
Michael Hulet
iOS Development with Swift Treehouse Moderator 46,347 Points

The implicit conversion is ok, though. The compiler is fine with it, and I like the style imo

Jennifer Nordell
Jennifer Nordell
Treehouse Moderator

Same Michael Hulet. I agree that return(0, 0) looks much nicer than return(0.0, 0.0) :smiley:

Jesse Gay
STAFF
Jesse Gay
Treehouse Staff

Thanks Jennifer and Michael! I've been staring at the screen too long and missed the typo :) Time for a break.