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 trialcsaba nemeth
2,554 Pointstuple 2 chalenge
func greeting(person: String) -> (language : String, greeting : String){
return ("English", "Hello \(person)")
}
var result = greeting("Tom")
whats wrong with this code at the 2 part of tuples?
func greeting(person: String) -> (language : String, greeting : String){
return ("English", "Hello \(person)")
}
var result = greeting("Tom")
3 Answers
Chris Shaw
26,676 PointsHi csaba nemeth,
You're very close, you simply have your return type backwards as greeting needs to comes first.
func greeting(person: String) -> (greeting: String, language: String) {
return ("Hello \(person)", "English")
}
var result = greeting("Tom")
csaba nemeth
2,554 PointsHi Chris,
Thank you very much! I am appreciated it.
Merry Chrismas!
Chris Shaw
26,676 PointsNo worries, and Merry Christmas to you too.
csaba nemeth
2,554 PointsActually the 3rd part is clear, but I don't really understand why confusing the students with this order thing :), everybody knows my code is works perfectly. Add names to return values makes the order pointless, actually thats why it exists.
I very grateful the help tough, cause I sucked about it for 2 hours.
arnavthecoder
3,453 Pointsarnavthecoder
3,453 PointsWhat about the 3rd part. It is very confusing, by the way..
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsTask 3 is the simplest part of the challenge and was explained in the previous video, any time you have a named tuple you can access it's value just like you would access a property in a
struct
.