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 trialRamon Bonte
1,981 Points[Swift] Tuples challenge 2 of 3. My code works in Xcode, but not on treehouse
I wrote this code for the challenge:
func greeting(person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language: language, greeting: greeting)
}
var result = greeting("Tom")
I seems right to me and Xcode doesn't give any errors or warnings. And variable result stores the tuple returned by greeting. But when i write the same code on treehouse. it keeps saying: βBummer! Your result
variable has the wrong value in it. Check the task instructions again.β So what is wrong ?
jimibarrolle
Courses Plus Student 953 PointsQuestion, Im a bit confused as well. Why or how is the order wrong? When you name the elements in the tuple, shouldnt the return tuple be... return (language, greeting) ..? Also what role do the 2 constants play in this? :(
David Baumgartner
1,308 Pointsjimi barrolle i really don't know! :(
3 Answers
Ramon Bonte
1,981 PointsThanks
Bradley Allen
5,224 PointsI was recently stuck on this too and would also like to understand why the order is reversed in the return. It doesn't mane any sense.
Amit Bijlani
Treehouse Guest TeacherSorry about the inconvenience but the way we are validating the challenge it is expecting the tuples in a certain order. The order is specified in the challenge instructions: Make sure to name each item in the tuple: greeting and language.
Bradley Allen
5,224 PointsThank you!
David Baumgartner
1,308 PointsDavid Baumgartner
1,308 PointsYour code was right. Just the order of the tuples items was wrong.