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

Samuel Kim
Samuel Kim
1,231 Points

"You need assign the return value of the 'greeting' function to 'result'." I do not understand what this means.

what do I do from here?

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

    return (language, greeting) 
}

var result = (language, greeting) 

1 Answer

Steven Deutsch
Steven Deutsch
21,046 Points

Hey Samuel Kim,

I just answered this question not too long ago. You should always check if your question has been answered previously on the forum. It can save you time that you lose in waiting for a response.

What you need to do is call your greeting function by passing it in a string, and then assign the value returned to a variable called result.

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

    return (language, greeting) 
}

/* You call your greeting function and pass it a string
because the function takes a String as its argument.
What will be returned is a tuple with the values of (language, greeting) */
var result = greeting("Samuel")

Here's my other post related to this question. Good Luck!