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 trialpolatutkukayrak
1,848 PointsBummer! Your `result` variable has the wrong value in it. Check the task instructions again.
I did the first step right and the second step basically asks me to: "Create a variable named result and assign it the tuple returned from function greeting. (Note: pass the string "Tom" to the greeting function.)"
So I created a new variable called "result" and assigned it to the greeting function which has the String "Tom" as an input. Since the variable "a" has two values in it, it returns two String values as the function wants ?
func greeting(#person: String) -> (greeting: String, language: String)
{
let language = "English"
let greeting = "Hello \(person)"
var a = ("\(language)", "\(greeting)")
return a
}
var result = greeting(person: "Tom")
3 Answers
Marlon Henry
6,885 Pointsvar result = greeting(person: "Tom") is only returning Greeting and the param that you had in it.
While (greeting, language) is returning greeting and language (and of course everything within those two)
Marlon Henry
6,885 Pointsfunc greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
polatutkukayrak
1,848 PointsYes it worked, thank you so much but I still don't get why my approach didn't work ?
When I put both codes in the playground, they both return the same result.
[Images of both codes in the playground] (Macintosh HD/Users/Utku/Desktop/Screen Shot 2015-07-07 at 3.16.19 PM.png "Screenshot")
Marlon Henry
6,885 PointsI don't know what the question is asking for but, you are only passing in one param but you asking to return two.
polatutkukayrak
1,848 PointsI did the first step right and the second step basically asks me to: "Create a variable named result and assign it the tuple returned from function greeting. (Note: pass the string "Tom" to the greeting function.)"
So I created a new variable called "result" and assigned it to the greeting function which has the String "Tom" as an input. Since the variable "a" has two values in it, it returns two String values as the function wants ?
PS : I'm sorry, I did edit the question