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!

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

Artem Zverkovskiy
Artem Zverkovskiy
1,090 Points

Parameters and Tuples

I don't understand exactly what should do. I suppose, I did everything but it doesn't work. Please tell me where are my mistakes?

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

    return greeting


2 Answers

Chris Shaw
Chris Shaw
26,663 Points

Hi Artem,

You have the general gist of what's been asked but have your code in the wrong spot and are missing the correct return type, so as you can see below the following has changed.

  • The tuple is where the return type String was
  • The return value within the greeting function now returns a tuple containing the greeting and language constants.
func greeting(person: String) -> (greeting: String, language: String) {
  let language = "English"
  let greeting = "Hello \(person)"

  return (greeting, language)

Happy coding!

Thank you. I was stuck here too. Practice practice practice...