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

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!