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 trialRoberto Quezada
2,673 Pointstested 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
Fabion Stephens
Courses Plus Student 5,893 PointsOh 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")
Roberto Quezada
2,673 PointsThat 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!
Fabion Stephens
Courses Plus Student 5,893 PointsFabion Stephens
Courses Plus Student 5,893 PointsAlso read that you can try naming your return values:
return (language: language, greeting: greeting)
Let me know which worked for you.
Matthew Chana
1,063 PointsMatthew Chana
1,063 PointsThank you Fabion!!!