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 trialMichael McKinley
1,476 PointsNot sure how to complete this println statement in my tuple
Please help!
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting("Tom")
println greeting(_, language)
3 Answers
Michael McKinley
1,476 PointsUsing the println statement, print out the value of the language element from the result tuple.
Andrew Shook
31,709 PointsMichael, first you have a syntax error. Println must be followed by an opening and closing parentheses.
println()
Also, you should use the result variable to access the language instead of using the greeting function again.
println( result.language)
tytyty
4,974 PointsNote: The instructions said 'element' so you could also use "println(result.1)". The task succeeded and the readability seems easier for me. But I think Amit said using .0 or .1 might not be best practice. Something about possible mix matches. Maybe someone could chime in. Thanks