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.

becky hayes
2,226 PointsTrying to assign a tuple to a variable and not sure how to do it!
The Challenge is this: Create a variable named result and assign it the tuple returned from function greeting. (Note: pass the string "Tom" to the greeting function.) and my code is attached. Having trouble knowing what the variable 'result' would look like and how i pass the string to Tom
func greeting(person: String) -> (language: String,greeting: String, result: String) {
let language = "English"
let greeting = "Hello \(person)"
var result = "Tom"
return (language, greeting, result)
}
1 Answer

Jhoan Arango
14,575 PointsHello Becky:
What the challenge is asking is for you to create a variable and assign it whatever the function will return to you.
I will modify your code just a bit, and then the rest you can do it. It will make sense once you see it.
func greeting(person: String) -> (language: String,greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language, greeting)
}
// Call the function and declare the variable here.
If you can't solve it or if there is anything that you do not understand, please let me know, and I can go into more details. So far you were doing great.
Good luck