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

I dont understand

I do not understand why we call the function greeting, then have the tuple named greeting along with the constant

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

    return (greeting, language)
}

3 Answers

The best answer I can come up with is, it was done to confuse you and make the challenge a bit more difficult. It seems a lot of people get stuck on the fact greeting is used various time.

Actually, I guess it's fairly likely greeting and language was used in multiple places to get us to realize that though three different elements have the name "greeting", they're not connected to each other. Function names, tuple parameters (or whatever they're called), and function properties are their own entities.

Thanks, if their goal was to confuse me, they succeeded .

Thanks, if their goal was to confuse me, they succeeded .

Thanks Ricardo, def not a smart move to do that with beginners, its hard enough as it is to understand the concepts...