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

Anne-Marie Angelo
Anne-Marie Angelo
556 Points

I have no idea how to solve this challenge.

I am trying to resolve this challenge, where I need to create a tuple that returns both greeting and language rather than just the greeting. How do I do this? Thanks.

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

} 

1 Answer

Hello Anne,

You can set the return value or values like this: (greeting: String, Language:String)...

Keep in mind once you tell the function you are going to return something you must return it

It should look something like return (greeting, language). See example below.

func greeting(person: String) -> (greeting: String, language: String) {

//Set your lets!


    return (greeting, language) // this is the important part : ) 
}

Let me know if you get stuck or need anymore help :)

Anne-Marie Angelo
Anne-Marie Angelo
556 Points

Thanks so much, Aaron! This was really helpful.