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 trial
Stephen Gehring
11,203 PointsI have no idea why this tutorial is returning an error? xcode says my code works like a charm?
func greeting(person: String) -> (language: String, greeting : String) { return ("English", "Hello (person)") }
var result = greeting("Tom")
Am I misunderstanding the question?
3 Answers
Jeremy Hayden
1,740 PointsStephen,
You forgot to name the tuples in your return statement.
return (greeting:greeting, language:language)
And you are missing both let statements.
func greeting(person: String) -> (greeting:String ,language:String){
let language = "English"
let greeting = "Hello \(person)"
return (greeting: greeting, language: language)
}
obey me
1,135 Pointsyou could try this but i know that the treehouse compile is not that smart so lol
func greeting ( person : String ) -> (greeting : String , language :String) {
let language = "English"
let greeting = "Hello \(person)"
var g = (greeting,language)
return g
}
Jeremy Hayden
1,740 PointsYour code will still give him an error He needs named tuples in his return ststement
obey me
1,135 Pointsmy code is good i used it
Stephen Gehring
11,203 PointsAhhh ok thanks... I thought naming them at the top of the function was good enough...
Thank you for the answers!
func greeting(person: String) -> (language: String, greeting : String) {
func greeting(person: String) -> (language: String, greeting : String) {
return (language: "English", greeting: "Hello (person)")
}
var result = greeting("Tom")