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 trialBarnabás Makkay
6,661 PointsI checked my code in a Swift Playground and it seems OK, but when I click "Check Work" the challenge doesn't accept it.
The task was to... Create a variable named result and assign it the tuple returned from function greeting. (Note: pass the string "Tom" to the greeting function.)
(Code attached)
func greeting(person: String) -> (language: String,greeting: String) {
return ("English","Hello \(person)")
}
var result = greeting("Tom")
Barnabás Makkay
6,661 PointsI think it might be a defect so I also reported it to the Treehouse Team.
I'll try not to forget and post the reply here.
Ferdinand Eugenio
555 PointsHi Makkay! I hope you doing great fond the solution for this. in the "return (language, greeting)" part we should turn around the language and greeting. so it look like this. " return (greeting, language). it's crazy!
Phil Hanson
764 PointsMine works in Xcode, but not in Treehouse.
func greeting(person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language, greeting)
}
var result = greeting("Tom")
Barnabás Makkay
6,661 PointsChange the keyword to let before result (let result = …). For me that did the trick.
1 Answer
Barnabás Makkay
6,661 Pointslet
instead of var
! ! !
Guys I solved my problem finally! Here's how:
Though the challenge asked me to create a "variable" (I assumed var), it turned out that it was waiting for a constant (let). As soon as I changed just this little thing in my code it was accepted. I sent a feedback to them about it. Hope this discovery will help you too :).
I don't really know how could I mark this post solved if you tell me how I will do.
Ferdinand Eugenio
555 PointsFerdinand Eugenio
555 PointsWe have the same code I though it's just me. I don't understand the challenge here.