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 trialRaymond Eddé
4,092 PointsPlease help
I am at the second step of the last tuple exercise and i am asked to: "Create a variable named result and assign it the tuple returned from function greeting. (Note: pass the string "Tom" to the greeting function.)
In Xcode, my "result" value is Hello Tom but in the exercise they give me the “You need assign the return value of the 'greeting' function to 'result’.”
Can someone please help me and tell me what I’m doing wrong?
3 Answers
Jhoan Arango
14,575 PointsRaymond:
Looking at your code there are a few things that you have to fix.
First part of the challenge says to return a tuple.
func greeting(person: String) -> (greeting: String,language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language) // We are returning the tuple
}
Second part, it says to create a variable.
var result = greeting("Tom")
Third part
println(result.language)
Hopefully this helps.
Good luck
Raymond Eddé
4,092 PointsThanks a Lot! That did the trick.
Raymond Eddé
4,092 PointsSo this is the code that works for e in Xcode:
func greeting (person: String) -> (greeting: String,language: String){
let greeting = "Hello \(person)"
let language = "English"
var found = (greeting, language)
return found
}
var (result,_) = greeting("Tom")
result
Eduardo Calvachi
6,049 PointsI also got caught by this one, make sure that the order of the returned tuple is the same order as named parameters of the function.
Jhoan Arango
14,575 PointsJhoan Arango
14,575 PointsHello..
Try posting your solution here, and we can help you with your problem.