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

I am stuck! Can someone help me! I will mark as best answer!

help

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

          return (greeting ,language)
           }

            var result = greeting("Tom")
            println("\(language)")

12 Answers

No! You are helping me with another code challenge! That's the problem!

Try only below

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

    return (greeting, language)
}

When you click on tuples.swift it takes you directly to the code challenge.

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

    return (greeting, language)
}

Not tuples.swift It is the first code challenge in the last stage of swift functions and optionals.

Hello, greeting function is returning a tuple. Since it is not named tuple you can do this:

let (greeting, language) = greeting("Tom")

then you can do

println("\(language)")

or

println("\(greeting)")

Can you help me with task 2!

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

    return (greeting, language)
}

let result = greeting("Tom")

Please review updated code.

Try below: You will need to set named tuple as return value then you can use it as result.language

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

    return (greeting, language)
}

var result = greeting("Tom")

Nope!

For setp2 you should not create var result = greeting("Tom") part i guess. Just remove that line

That is all wrong!

It's search.swift

Oh I just forgot! I past that code challenge!

I don't understand you! Can you paste some code!

I think you guys are helping me with something else