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 trialAlex Lobert
2,736 PointsHey, I can't seem to get result to have the write values. Can someone help me with the 2nd part of this challenge?
This is my code:
func greeting(person: String) -> (language: String, greeting: String) {
let greeting = ("English", "Hello \(person)")
return greeting
}
var result = greeting("Tom")
2 Answers
Ricardo Hill-Henry
38,442 PointsYour problem is actually in the first step (1/3). I'm not sure why you were allowed to proceed to the second step. You've set greeting to return a tuple, however you're still only returning greeting, a string.
With this error, result will never hold a tuple, because because greeting will never return a tuple.
func greeting(person: String) -> (language: String, greeting: String) {
let greeting = ("English", "Hello \(person)")
return (greeting, language) //where your error occured
}
Alex Lobert
2,736 PointsThat makes sense. Thank you!