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 trialBruno Fernandes
2,413 PointsCompletely stuck in Task 3
This is the first challenge that I get completely stuck, either I have to re-watch all the chapter again, or this exercise needs some more explanation. :(
func greeting(#person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting(person: "Tom")
println(greeting.language)
1 Answer
Ricardo Hill-Henry
38,442 PointsThe task says to print out the value of language from the instance of greeting, "result." What you're doing is calling it on the greeting function itself.
println(result.language)
Bruno Fernandes
2,413 PointsBruno Fernandes
2,413 PointsAnd how do I do this? I still don't know it what I have to do...
Bruno Fernandes
2,413 PointsBruno Fernandes
2,413 PointsOk, for some reason it only worked after I inverted
(language: String, greeting: String)
to(greeting: String, language: String)
is this something I did wrong or a bug in the simulator?Ricardo Hill-Henry
38,442 PointsRicardo Hill-Henry
38,442 PointsOh, I didn't even notice that. It may have something to with at the top you've said you want to return (language: String, greeting: String), but at the end of the function you return it in this order: (greeting, language)
Now that shouldn't affect the output of result.language, however, the challenge may have been checking all your work to make sure there weren't any other errors (which in this case there were).