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'm not sure how to make it to tuple?

Is language a boolean value? Did I over think this question?

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

    return greeting

1 Answer

Dominic Bryan
Dominic Bryan
14,452 Points

Hi xiaohu li, this was answered brilliantly by Chris Upjohn over at: https://teamtreehouse.com/forum/not-sure-on-the-tuple-question-ios-swift-to-modify-the-greeting-to-return-both-language-and-greeting

To answer it here for you, you slightly over thought it in respect to you are still in the mind set of the video before the question, there is no bool value in this question. Language is a String = "English". To return these values you must change the return statement along with the return type:

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

    return (greeting, language)

AS you can see return is now a tuple of greeting and language, and the return type is now greeting as type string and language also of type string.

Hope this helped


Thank you for your help! I missed the first line: language: String part.