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 trialLi Lin
5,007 PointsHow am I not returning the greetings function to result?
On the Tuples 2/3 Challenge, I have:
func greeting(person: String) -> (greeting: String, language: String) { let language = "English" let greeting = "Hello (person)" var result = (greeting,language) return (greeting,person) } result("Tom")
I keep getting an error saying I have to get the greetings functions to result.
Anybody can shed any light on this? Thanks
2 Answers
Stone Preston
42,016 Pointsfirst, your greeting function is not correct. you have this right now:
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
var result = (greeting,language)
return (greeting,person)
}
you are returning (greeting, person) instead of greeting language (which you have assigned to result). I would remove the result variable and just return the tuple like so:
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting,language)
}
then you need to call the greeting function with "Tom" as an argument and assign the return value of that to a variable called result.
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting("Tom")
Li Lin
5,007 Pointsthanks for the explanation Stone!