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 trialRoss Weeden
1,930 Pointstuple help. no idea what i'm meant to be doing here to return two statements. any help appreciated
hh
func greeting(person: String) -> String {
let language = "English"
let greeting = "Hello \(person)"
return (greeting (person:"Tom", language,"English"))
}
2 Answers
Michael Reining
10,101 PointsHi Ross,
You are very close. To return a tuple, you return two objects separated by a comma like this.
return (firstItem, secondItem)
When you apply this to the challenge it looks like this
func greeting(person: String) -> (String, String) { // update return definition
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
While the above is a valid function for the challenge they want you to also label each of the returned values like this.
func greeting(person: String) -> (greeting: String, language: String) { // update return definition
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
Tuples are great but can be very hard to grasp at first. At least I struggled with them a bit. I launched an app to help others learn Swift. There is a chapter on tuples in it that might help.
Mike
PS: Thanks to the awesome resources on Team Treehouse, I launched my first app. :-)
Ross Weeden
1,930 Pointsthanks to all who answered. Much appreciated. Hopefully I'll be tupling with the best of you soon.
Josh Minor
2,947 PointsJosh Minor
2,947 PointsYou're doing good, sometimes the questions can be unclear.
Here is my solution.