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 trialJake N
612 PointsStuck
I got part one but I'm stuck on part 2 an 3, I'm not sure where to start on this one
func greeting(person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting,language)
}
3 Answers
Chris Shaw
26,676 PointsHi Jake,
You simply have your return type backwards, greeting
should be first then language
.
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting,language)
}
var result = greeting("Tom")
Jake N
612 Pointsit says i need to define result
Chris Shaw
26,676 PointsSorry Jake, I forgot you said task 2 in your initial post, I've updated my response to include this.
Jake N
612 Pointsthanks, I'm not able to get the third part either
Chris Shaw
26,676 PointsHi Jake,
The 3rd task is as follows:
Using the
printl
n statement, print out the value of thelanguage
element from theresult
tuple.
So what this is asking us to do is print the value for result.language
which because we're using named tuples we can access simply via language
whereas if we didn't name it we would have to access it via 1 instead.
You can read far more about this in another post I made a while back.
println(result.language)
Happy coding!