Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.