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 trialFahim Karim
2,181 PointsSwift Functions Stage 2 Challenge 2
func greeting(person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language, greeting)
}
let result = greeting("Tom")
I keep getting Your 'result' variable has the wrong value. In the Xcode playground everything seems to be ok.
1 Answer
Suck It
1,527 PointsHey your return was wrong instead of: return (language, greeting) its:
return (greeting, language)
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
let result = greeting("Tom")
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsI've updated your return types order as it was still the wrong way around.
Fahim Karim
2,181 PointsFahim Karim
2,181 PointsThanks, that worked. Since it is a named tuple, does the order matter?
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsNo it doesn't, when you're using anything that's named you can specify it out of order such as the below example, all you need to do is simply reference the named value and assign it.