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

Stan Calderon
Stan Calderon
1,810 Points

I pasted the code in playgorund and got the result "Hello Tom" but i keep getting an error saying wrong value.

I keep getting an error saying result was passed the wrong value. I am getting the result "Hello Tom" with zero errors when I copied this code in playground. Can someone point out my mistake. Thanks.

tuples.swift
func greeting(#person: String) -> (language: String, greeting: String) {
    let language = "English"
    let greeting = "Hello \(person)"

    return (language, greeting)
}
var result = greeting(person: "Tom")

3 Answers

you are on the right track ,I think the return should be greeting then language but you have the inverse..

    func greeting(#person: String) -> (greeting: String, langiage: String) 
        {
           let language = "English"
               let greeting = "Hello \(person)"

              return (greeting, language)
         }
                 var result = greeting(person: "Tom")

You've done everything right, except it was expecting the result tuple values to be the other way round. See below:

func greeting(#person: String) -> (language: String, greeting: String) {
    let language = "English"
    let greeting = "Hello \(person)"

    return (greeting, language)
}

var result = greeting(person: "Tom")

Just swap the positions of greeting and language.

like I said lol

Stan Calderon
Stan Calderon
1,810 Points

Thanks guys. Was this just Treehouse being picky or is there a reason it must go in this order?

Treehouse picky