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 trialroberth3
3,940 PointsHelp on tuples.
This is asking me to "return both the greeting and the language as a tuple. Make sure to name each item in the tuple: greeting and language. ", and I don't quite get what is wrong here.
More Info: Challenge Task 1 of 3
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return greeting
}
1 Answer
Chris Shaw
26,676 PointsHi roberth,
You're almost there, when we declare a function return type as a tuple we also need to ensure our return
statement matches that. As Amit demonstrated, we can create a tuple by using opening and closing parentheses which contain our tuple values separated by a comma between each value.
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
That's all that's to it, I recommend you have a read of another post I made a while back which others have found valuable.
Happy coding!