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 trialDaniel Karanitsch
877 PointsStuck in part 2 of the Tuple-Challenge (your `result` variable has the wrong value in it)
This is my code, it works when pasted into xcode.
But here I get an error and the message "...result
variable has the wrong value in it ... read the instructions..."
Did I get the question wrong?
func greeting(#person: String) -> (language: String,greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language, greeting)
}
var result = greeting(person: "Tom")
2 Answers
Cristian Altin
12,165 PointsYou can both call greeting("Tom") or greeting(person: "Tom") since the function only receives one named variable but the problem is NOT there. ;-)
The exercise was asking to pass greeting first and then language in the tuple. That's all really, your code works but you switched the return elements in the tuple.
kjvswift93
13,515 PointsThe second task says to "create a variable named result and assign it the tuple returned from function greeting". This is done like this:
var result = greeting("Tom")
Daniel Karanitsch
877 PointsDaniel Karanitsch
877 PointsThank you. Now it works :)