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

There is something wrong with this exercise. I tested my answer on playground and it works as expected but not here.

There is something wrong with this exercise. I tested my answer on playground and it works as expected.

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

    return (language,greeting)
}
let result = greeting("Tom")

3 Answers

Hi,

What's the question you are being asked?

You've created a function that takes String as an incoming parameter and returns two parameters.

You generate two method constants inside the method. You return them both.

You then create a constant using the output of the function.

What was the question you were asked to answer here?

Steve.

I found the problem. The first part of the exercise assumes that return (language,greeting) is the correct answer. But then this cause conflict on the second.

The correct outcome should be return (greeting,language)

I'd be surprised if the issue was a Treehouse one. Any assumption made may not be theirs.

Have a look through precisely what was asked for. But don't dwell on it as you've got beyond this challenge.

Good luck!