Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Functions and Optionals Parameters and Tuples Tuples

William Bergstein
William Bergstein
2,078 Points

What exactly are Tuples? Is the combination of two strings within () a tuple?

I thought that I was doing this right but I keep getting an error. I don't understand why this is happening.

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

    return greeting

1 Answer

In Apple's Swift documentation, tuples are described as a list of zero or more elements, separated by commas, enclosed in parentheses.

For the purpose of function return values we're going to assume a tuple is a list of two or more items, separated by commas, surrounded by parentheses.

The task instructions tell you to change the return value into a tuple. Your guess in the title is very close to the right answer! Can you figure it out now?