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

Alexandra Kaplan
Alexandra Kaplan
1,167 Points

I have done the best I can do on this problem and need help

It asks to create a tuple that attaches a language and a greeting to a code already created that will input a name into a function greeting.

First of all, I thought you can't use a specific title for two different things, so how can I put in greeting as a tuple if it is the name of the function?

Second of all, when I write my code, it says that language is an unidentified variable, but says nothing about the word greeting right after it.

I am getting VERY frustrated.

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

    return greeting
}

let greeting(language, string)=(person: "Tom")

1 Answer

Try this. You also spelled language wrong up top when you were setting up your parameters.

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

    return (language, greeting)
}
Alexandra Kaplan
Alexandra Kaplan
1,167 Points

It worked! Ah, thank you so much. Would you mind looking at my new question about the third tuple challenge?