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

Paul Cullen
Paul Cullen
1,414 Points

Xcode compiles this tuple correctly, but online editor does not.

Hey

The current task for the tuples section is to assign the result of the greeting to a variable called result, i have tried the below, which returns a single string variable in result of "Hello Tom" and ive tried changing the result to be a tuple itself eg:

var result = greeting("Tom")

Neither pass the test, im wondering what im doing wrong? I have already completed the extra credit assignment but cannot get past this code validation issue.

Thanks!

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

    return (language,greeting)
}

var (_,result) = greeting("Tom")

the problem is the variable name (, result). ( and , are not appropriate variable characters. when returning a tuple a normal name like result will be able to hold it. You do not need to have a strange (,result) format.

so var result = greeting("Tom") should work fine.