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 see what i did wrong here, please help me...

Can you please help me to correct this code? It works fine in playground returning what you ask.

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 House":
        return (33.8587,151.2140)
    default:
        print("error--location not found.")
        return (0,0)
    }
}

1 Answer

Jorge Solana
Jorge Solana
6,064 Points

You will find in many cases that your code in playground works perfectly fine, but the Challenge Task wants you to code it in a specific way. In this challenge, you might want to read again that:

(Note: You do not have to name the return values).

Try with this one

// 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 "Sydney Opera House":
      return (33.8587,151.2140)
    default:
      return (0,0)
  }
}

MODERATOR EDIT: Moved response from Comment Section to Answers, as it answers the question posted. It can now be upvoted and/or marked Best Answer.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Hey there Jorge Solana

Thank you so much for your participation in the Community Forums. Your helpfulness and well explained responses are very appreciated. :smile:

If you could, however, place your responses as an "Answer" and not a "Comment", it will be better reflected in the Forum. Others can then see an answer has been provided, and have a peek if they like. Also, your answer can be up-voted and/or marked as "Best Answer" which add points to your profile.

Keep up the great work!

Jason Anders - Treehouse Forum Moderator :dizzy: