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 trial
Laurence Bowe
6,222 PointsCode Challenge Tuples - Part 3
Hi,
I'm completely confused on this last part and I don't know where this is going wrong, I know it seems like a beginner task but.... Please help THANKS SO MUCH IN ADVANCE Using the println statement, print out the value of the language element from the result tuple.
func greeting(person: String) -> (greeting: String,language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting("Tom"),language("English")
println(result.1)
THNAKS AGAIN!!! :) (:
5 Answers
Tim Jensen
2,416 PointsThe right command is println(result.language)
That is because you call the result, but you only want the language string that is why you use the .language
Ethan Lowry
Courses Plus Student 7,323 PointsSeems like it wants you to access the value using the element's name, rather than the fairly unpleasant looking .0, .1 etc. Try swapping out your .0 for something else and see how it goes.
(Also it's hard to tell with your code all in one big like like that, but make sure you are calling and passing parameters to your greeting function correctly in terms of where you put brackets, colons etc. You may want to go back and re-watch this stage of tutorials if you can't quite remember.)
Jack Hawley
10,665 PointsGive this a try:
println(result.language)
Ariel Foreman
3,447 Pointsvar result = greeting("Tom")
println(result.1)
Sreenivasa Madenahally
1,072 Pointsjust type println(result.1)