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

basmah Almashari
basmah Almashari
1,521 Points

ERROR: the 'result' variable has a wrong value in it

hello i tried to figure out what the wrong in this code but still give me an error

```swift func greeting (person: String) ->(greeting: String , language: String){ return ("English","Hello (person)") } var result = greeting("Tom")

```tuples.swift
func greeting (person: String) ->(greeting: String , language: String){


    return ("English","Hello \(person)")
}


var result = greeting("Tom")

2 Answers

Hi there,

You're nearly there. You nee to amend the return value (after the ->) to return two named strings. Then amend the return statement to do the same. You end up with:

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

    return (greeting, language)
}

Hope that helps.

Steve.

basmah Almashari
basmah Almashari
1,521 Points

thank you Steve, it works that way

No problem. Glad to help! :-)