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 Swift Functions and Optionals Parameters and Tuples Tuples

joshua landon
joshua landon
2,418 Points

I've watched the videos 10 times each and still can't figure out the answered to this tuples question. I need help.

Where can I get the answer to this question before I throw my laptop out the window. It is getting very frustrating.

It is the last challenge in the first Swift - functions lessons

I'm not sure which last challenge you are talking about. The first and third part of Swift Functions and Optionals have questions that have nothing to do with Tuples. But the second part does. So here are the answers to the last questions of each part's challenge:

The answer to the last challenge in Swift Functions and Optionals -> Functions is:

func greeting(person: String) -> String {
    return("Hello \(person)")
}

The answer to the last question of the challenge Swift Functions and Optionals -> Optionals is:

func greeting(person: String) -> (greeting: String, language: String) {
    let language = "English"
    let greeting = "Hello \(person)"

    return (greeting, language)
}

var result = greeting("Tom")

println(result.language)

and the last challenge in Swift Functions and Optionals -> Optionals is:

func isNotDivisible(#dividend: Int, #divisor: Int) -> Bool {
  if dividend % divisor != 0 {
    return true
  } else {
    return false
  }
}

2 Answers

Hi, here is my solution:

func greeting(person:String) -> (greeting:String, language:String) {

let language = "English" let greeting = "Hello (person)"

return (greeting, language)

}

hope it helps.

David Gieseke
David Gieseke
1,662 Points

Awesome!!!!

I had the same problem. Good answer!

I just had to fine tune the ......"Hello (person)" with the back slash as in......."Hello (person)"

Thank you very much!!!!