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

Roberto Quezada
Roberto Quezada
2,673 Points

tested locally and result variable is returning the correct tuple values. What's the issue here?

not sure what I am missing in my code?

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

return (language, greeting)
}

var result = greeting("Tom")

2 Answers

Oh i see.. change the order of the tuples and the order in which they are being returned. Not sure why it matters but that should work. Let me know. Here is what i have in case you still don't get this to work:

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

    return (greeting, language)
}

var result = greeting("Tom")

Also read that you can try naming your return values:

return (language: language, greeting: greeting)

Let me know which worked for you.

Thank you Fabion!!!

Roberto Quezada
Roberto Quezada
2,673 Points

That did it! I simply changed the order in which the tuples were being returned. I am also not sure why this matters or not. Must be something they would need to look into as part of their code validation logic in the course.

Thanks again!