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

Andrew Condon
Andrew Condon
699 Points

I'm asking it to return two strings...but I don't think I'm doing this right at all. I'm lost.

Not sure exactly what else I have to do?

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

    return greeting
}

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Andrew,

You're almost there, you just need to return a tuple based on the return type you set for the greeting function like below.

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

  return (greeting, language)
}

Happy coding!

Andrew Condon
Andrew Condon
699 Points

Ah, great thanks!

I think the exercise is a lot simpler than the lesson before it. For some reason I tried all types of other stuff that was totally unnecessary.