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

iOS Swift Functions and Optionals Parameters and Tuples Tuples

I 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

Stephen,

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)
}​

you 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

               }

Your code will still give him an error He needs named tuples in his return ststement

my code is good i used it

Ahhh 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")