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 getting an error I just don't understand

This is the code I am using

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

return greeting

}

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

    return greeting
}

1 Answer

Jhoan Arango
Jhoan Arango
14,575 Points

Hello Alex:

You are doing great, so far you are only missing to properly return on the tuple.

Since you created a tuple as a return type, you want to be able to β€œReturn” the values in the tuple.

                                    // Tuple as a return type
func greeting(person: String) -> (greeting: String, language: String) {
    let language = "English"
    let greeting = "Hello \(person)"

    return (greeting,language) // Returning the values from the tuple
}

Hope this helps, please let me know if you need more help.

Thank you!