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 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)].