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 trialHyun Seo Chung
2,239 PointsThe code runs in Xcode
The code for this challenge runs in Xcode without any error, but says incorrect in the challenge, and I am having some trouble finding what is actually wrong. I tried changing things around a bit but it still didn't quite work for some reason. Thanks.
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
1 Answer
Steve Hunter
57,712 PointsWhat did the challenge ask you to do? This is returning two Strings after modifying one of them with the parameter the function takes.
This returns a tuple. So,
greeting("Steve")
returns a tuple of .0 "Hello Steve", .1 "English"
This can be accessd in dot notation such as; greeting("Steve").0
is "Hello Steve"
and greeting("anystring").1
is "English"
.