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

Functions in Swift

func coordinates(for location: String) -> ( Double, Double) { if location == "Eiffel Tower" { return (48.8582, 2.2945) } else if location == "Great Pyramid" { return (29.9792, 31.1344) } else if location == "Sydney opera House" { return (33.8587, 151.2140) } else { return (0,0) }

}

functions.swift
// Enter your code below
func coordinates(for location: String) -> ( Double, Double) {
    if location == "Eiffel Tower" {
        return (48.8582, 2.2945)
    } else if location == "Great Pyramid" {
        return (29.9792, 31.1344)
    } else if location == "Sydney opera House" {
        return (33.8587, 151.2140)
    } else {
        return (0,0)
    }
}

4 Answers

Hi Manoj,

Sydney Opera House has a capital 'O'. Your code is fine if you change that.

But I'd suggest using a switch statement as it is neater:

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)
  }
}

Steve.

I have tried both. Switch statement was fine but if else case was giving me an error. I have been checking over return values but haven’t checked location.

Yeah - the tests are very specific so are case sensitive - changing 'opera' to 'Opera' will fix your if/else code. :+1:

Thanq steve. It was great tutorials. Could you please suggest me some interview questions.

What sort of interview? Are you leading the interview or are you the candidate?

Iam the candidate.. what kind of questions do can i expect.

I'd be asking questions about the job description - provide examples of how you can perform the tasks required, work as a team player, be a self-starter. Then I'd be asking questions about what the candidate knows about the business/company - why will they be a good fit; where do they see their career developing in the business. I'd be asking about the candidate's knowledge of the field the business operates in - how do they remain up to date with developments, how well known are they within the market, what contacts does the candidate bring, how will they be better connected in this role, why does the role represent a career progression, will the candidate's future plans move them away from the business?

Just some thoughts. I've not done interviews for a while but they usually focus on key competencies and then explore how the candidate's experience fits with the role/team/company.

I hope that helps.

Steve.