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 trialJerrett Fowler
3,614 PointsWhy is "var result = greeting("Tom")" incorrect? It works in the playground.
I can't tell if I'm totally misreading the challenge or what.
Jerrett Fowler
3,614 Pointsfunc greeting(person: String) -> (language: String, greeting: String) {
return (language: "English", greeting: "Hello \(person)")
}
var result = greeting("Tom")
3 Answers
Ethan Lowry
Courses Plus Student 7,323 PointsThis seems dumb as the code you've provided is valid as far as I can tell, but can you try swapping the order of your arguments in the greeting function? i.e. have greeting then language (and remember to update the order in the return statement too).
This really shouldn't matter, but it might be that the Treehouse challenge specifically is being picky even though your code is technically fine. I did the challenge quickly and did nothing differently from you other than the above, and it worked fine.
...Or, maybe I'm being blind and missing something else :)
Jerrett Fowler
3,614 PointsThat worked. Thank you so much. I feel a bit silly since it was so easy.
kjvswift93
13,515 PointsYou need to initialize the two constants language and greeting. This is what the code should look like...
func greeting(person: String) -> (greeting: String, language: String) { let language = "English" let greeting = "Hello (person)"
return (greeting, language)
} var result = greeting("Tom")
Jerrett Fowler
3,614 PointsSorry Kyle, that doesn't seem to be helping me at all. It's not accepting that, either.
Alejandra González
947 PointsI need help with task 3 for this challenge! "Using the println statement, print out the value of the language element from the result tuple." Where is this result tuple? I have done the 2 previous tasks right.
Thanks
Logan R
22,989 PointsYou will most likely be able to get better help for your problem if you make your own question on the forums :)
Logan R
22,989 PointsLogan R
22,989 PointsCan you please post your code? It will help us find your problem :)