Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Functions and Optionals Parameters and Tuples Tuples

i don't know how to add elements to the tuple


Can you post what you've tried, then we can try to help from there. Likely, it's a matter of just rewatching the video or viewing the documentation to get a better understanding.

Taylor Weeks
Taylor Weeks
4,009 Points

This was a tricky exercise for me, but I did figure out what it is asking for. After the "->" (which is where you specify what the function will return), you need to name the two strings that will be returned using a colon to separate the name and the type (e.g. found: Bool, description: String).You will also need to make sure the function returns the two values (greeting, language).

I have tried this code:

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

return  language - greeting


1 Answer

Taylor Weeks
Taylor Weeks
4,009 Points

Osman, your code looks good except for the return line. The syntax for returning a tuple is parentheses with the values separated by a comma. You are also missing a backslash before person in your greetings constant [(person)].