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 trialAR Ehsan
7,912 PointsI am stuck! Can someone help me! I will mark as best answer!
help
func greeting(person: String) -> (greeting : String,language : String ){
let language = "English"
let greeting = "Hello \(person)"
return (greeting ,language)
}
var result = greeting("Tom")
println("\(language)")
12 Answers
AR Ehsan
7,912 PointsNo! You are helping me with another code challenge! That's the problem!
jason phillips
18,131 Pointsfunc greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
AR Ehsan
7,912 PointsNot tuples.swift It is the first code challenge in the last stage of swift functions and optionals.
Yalamber subba
10,943 PointsHello, greeting function is returning a tuple. Since it is not named tuple you can do this:
let (greeting, language) = greeting("Tom")
then you can do
println("\(language)")
or
println("\(greeting)")
AR Ehsan
7,912 PointsCan you help me with task 2!
jason phillips
18,131 Pointsfunc greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
let result = greeting("Tom")
Yalamber subba
10,943 PointsPlease review updated code.
Yalamber subba
10,943 PointsTry below: You will need to set named tuple as return value then you can use it as result.language
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting("Tom")
AR Ehsan
7,912 PointsNope!
Yalamber subba
10,943 PointsFor setp2 you should not create var result = greeting("Tom") part i guess. Just remove that line
AR Ehsan
7,912 PointsThat is all wrong!
AR Ehsan
7,912 PointsIt's search.swift
AR Ehsan
7,912 PointsOh I just forgot! I past that code challenge!
AR Ehsan
7,912 PointsI don't understand you! Can you paste some code!
AR Ehsan
7,912 PointsI think you guys are helping me with something else
Yalamber subba
10,943 PointsYalamber subba
10,943 PointsTry only below
jason phillips
18,131 Pointsjason phillips
18,131 PointsWhen you click on tuples.swift it takes you directly to the code challenge.