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 trialJordan Nilsson
1,409 PointsHow do I complete task 2 of this challenge?
I understand how to create a variable and to name it result, but I don't understand the part about assigning it to the tuple. What do I do to complete this task?
func greeting(person: String) -> (language: String,greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
var result = (language,greeting)
return (greeting,language)
}
2 Answers
Jhoan Arango
14,575 PointsYou are close, just put the variable outside the function. And call the function to that variable.
truemaulik
Courses Plus Student 7,765 PointsHere is the complete answer
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting("Tom")
println("\(result.language)")
The question asks to create a variable name result and store the value returned by the function greeting.
var result = greeting("Tom")
Jordan Nilsson
1,409 PointsI really appreciate the time you took to help me! Thank you so much!
truemaulik
Courses Plus Student 7,765 PointsMost welcome.
Jordan Nilsson
1,409 PointsMaulik, do you know the opposite of ==?
truemaulik
Courses Plus Student 7,765 PointsThe Opposite of == is !=
let number = 3
if number != 4 {
println("The number is not equal to 4.")
}
The above block of code will print "The number is not equal to 4." because the var number is not equal to 4
Jordan Nilsson
1,409 PointsJordan Nilsson
1,409 PointsThank you for your help!