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

tuples 3/3

hai!

i dunno how to this challange for the pt3 i think im being really really stupid now! cause i think everyone else has got this and i think im the only one who doesnt understand this!! I have got through basics and this fine untill now!!

My code:

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

    println("\(language)")


}

var result = greeting("Tom")
Christian Kristoffersen
Christian Kristoffersen
32,531 Points

Hey Ben, You have to print it out like this:

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)

thanks so muchhhh!!!!!!! it makes sense now!!! :D

1 Answer

The challenge wants you to get the language element from the tuple that resuly currently holds. What you're doing is having every tuple created using greeting print out language.

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)

thanks!!!!!! i get it now!!!