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

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!