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 trialsassyn
5,981 PointsVariable has wrong value
func greeting(person: String) -> (language: String, greeting: String) { let language = "English" let greeting = "Hello (person)"
return (language, greeting)
}
var result = greeting("Tom")
Why does the result variable not have the right value?
func greeting(person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language, greeting)
}
var result = greeting("Tom")
1 Answer
Christopher Augg
21,223 PointsSassyn,
Sorry for the error, It appears that the test wants a specific order for greeting and language. You will need to swap the order like so.
func greeting(person: String) -> (greeting: String, language: String) { //greeting then language
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language) //greeting then language
}
var result = greeting("Tom")
Regards,
Chris
Pasan Premaratne
Treehouse TeacherPasan Premaratne
Treehouse TeacherThanks for the heads up Christopher Augg. We'll get this fixed on our end!