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

What am I doing wrong? It has no compiler errors but it still doesn't allow me to advance

Help

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


    return language
}

var result = greeting("Tom")
Enrique Munguía
Enrique Munguía
14,311 Points

Maybe the exercise expects that you define two variables and return them as a tuple.

1 Answer

Stepan Ulyanin
Stepan Ulyanin
11,318 Points

Hi, you are returning only one value not 2 as a tuple, you need to specify the tuple at your return statement:

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

    return (language, greeting)
}

var result = greeting("Tom")