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

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.

tuples.swift
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?