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 trialEugen Pirogoff
3,278 PointsHey folks. Sometimes your online editor is having troubles with some code like this here. i have it running in xcode.
func greeting(person: String) -> (String, String) { var result:(greeting: String, language: String) result.language = "English" result.greeting = "Hello (person)" return result }
this is considered as not working by your editor.
2 Answers
Daniel Marin
8,021 PointsEven if that code is runing, this is the correct way of doing it since later on you can access the greeting values
Simply use the function and you will see, I was thinking the same as you at first...
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
let salute = greeting("Tom")
salute.language
salute.gretting
Eugen Pirogoff
3,278 PointsThnx on that.