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

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?