Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Functions in Swift Adding Power to Functions Returning Complex Values

nader adam
PLUS
nader adam
Courses Plus Student 548 Points

where is the wrong here

// Enter your code below func coordinates(for location: String) -> (Double , Double) { return value }

let value = coordinates(for: "Eiffel Tower") value.0 value.1

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

let value = coordinates(for: "Eiffel Tower")
value.0
value.1

1 Answer

Michael Afanasiev
PLUS
Michael Afanasiev
Courses Plus Student 15,596 Points

Hi Nader,

For this challenge, we can use switch statements

I will try to give you some hints so you can complete it yourself! ?

// Declaring the function (You got that exactly right!)
func coordinates(for location: String) -> (Double, Double) {
    switch location {
  // Choose your 3 cases below and return their longitude and latitude   
       case "some location":  return (1.234567, 2.4567891)

 // After choosing your cases, don't forget that we need to add a default state as per the challenge 
// "If a string is passed in that doesn’t match the set above, return (0,0)"
  }
}

I hope this helps a bit, let me know if there is still something you don't understand. ✌️