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

Geert Van Campenhout
Geert Van Campenhout
7,308 Points

Tuples Task 1 of 3

I don't know what I'm doing wrong, nor how to move on... this is what I have:

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

return greeting

}

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

    return greeting
}

3 Answers

Hi there

You've got the method signature amended correctly - you now need to amend the method body to return the two variables:

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

    return (greeting, language)  // <- change to this!
}

Hope that helps !

Steve.

Geert Van Campenhout
Geert Van Campenhout
7,308 Points

Awesome, it worked! Seemed that I was close. Unfortunately teamtreehouse doesn't hint you on what's missing or might be wrong like Khanacademy does.. Thank you for your answer Steve!

Hi,

If you clicked the preview button when you get an error, it shows you the compiler messages. In this case the error would have shown:

swift_lint.swift:11:12: error: 'String' is not convertible to '(greeting: String, language: String)'
    return greeting
           ^

That can help pin down the precise issue with the code.

Steve.

Geert Van Campenhout
Geert Van Campenhout
7,308 Points

I did, but such error messages are Chinese for me at this moment :-)

Ah, yes. At first, they make little sense! :-)