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

mitchell daw
mitchell daw
2,407 Points

I am really confused as to what they want us to modify in this code. Any hints?

What is the first step?

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

    return greeting
}
Helgi Helgason
Helgi Helgason
7,599 Points
func greeting(person: String) -> (greeting: String, language: String) {
    let language = "English"
    let greeting = "Hello \(person)"

    return (greeting: greeting, language: language)
}

Change the function so it will return a tuple

1 Answer

Hi Mitchell,

As the Challenge is asking for both greeting and language to be returned as a tuple, you'd want to include that each is a string being returned - not just a single string, then just add the language to the return statement.

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

    return (greeting, language)
}

Hope that helps!