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

What's wrong here? var result = greeting("Tom") //Error: Your `result` variable has the wrong value in it.

I cannot pass beyond this point. I use a playground in Xcode and it compiles find.

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

    return (language, greeting)
}

//Your `result` variable has the wrong value in it. 
var result = greeting("Tom")

1 Answer

Stone Preston
Stone Preston
42,016 Points

task 1 states: Make sure to name each item in the tuple: greeting and language

this challenge is quite picky and expects greeting to come first, then language

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

    return (greeting, language)
}

var result = greeting("Tom")

Amit Bijlani, any way you can modify the challenge to accept it regardless of the order of the tuple elements?

Oh! Thanks!

Stone Preston
Stone Preston
42,016 Points

no problem. glad I could help

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Thanks Stone. I'll look into it or at least add a hint.

Gareth Gomersall
Gareth Gomersall
2,890 Points

Yeah this was a bit confusing to be honest....... why does it expect greeting to come first?