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 trialStan Calderon
1,810 PointsI pasted the code in playgorund and got the result "Hello Tom" but i keep getting an error saying wrong value.
I keep getting an error saying result was passed the wrong value. I am getting the result "Hello Tom" with zero errors when I copied this code in playground. Can someone point out my mistake. Thanks.
func greeting(#person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language, greeting)
}
var result = greeting(person: "Tom")
3 Answers
Meek D
3,457 Pointsyou are on the right track ,I think the return should be greeting then language but you have the inverse..
func greeting(#person: String) -> (greeting: String, langiage: String)
{
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting(person: "Tom")
Jonathan Cousins
4,160 PointsYou've done everything right, except it was expecting the result tuple values to be the other way round. See below:
func greeting(#person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting(person: "Tom")
Just swap the positions of greeting
and language
.
Meek D
3,457 Pointslike I said lol
Stan Calderon
1,810 PointsThanks guys. Was this just Treehouse being picky or is there a reason it must go in this order?
Jonathan Cousins
4,160 PointsTreehouse picky