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 trialJon Schenck
2,028 Pointshelp with tuples please
Cant get this to work. Please help
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
var result = greeting("Tom", "English")
println(language)
2 Answers
Fuad Adetoro2
iOS Development Techdegree Student 2,870 PointsRemember that the only parameter you're calling is "Person" so when you create your variable you don't need to pass the language!
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)
Chengyu Deng
7,879 PointsIf you want to call the greeting function, you only need to enter the parameter which in this case the parameter is person.
The code should be like:
Then you can print the language out by println(result.language)