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 created a var named result and assigned to greeting. I'm I doing something wrong?

Create a variable named result and assign it the tuple returned from function greeting. (Note: pass the string "Tom" to the greeting function.)

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

    return (language,greeting)
}
 var result = greeting("Marcus")

result.greeting

4 Answers

Luiz Eduardo Negrato Casali
Luiz Eduardo Negrato Casali
557 Points

I've noticed that most of times the site will check for a specific syntax or code. Even the variables content. for example, if they ask "Tom" they will say that "tom" is wrong. In your code you are using a string "Marcus". Try that.

Luiz Eduardo Negrato Casali
Luiz Eduardo Negrato Casali
557 Points

that is how i did it.

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

return (greeting, language) }

var result = greeting("Tom") println(result.language)

I still get a error, but when I run it on playground everything works out fine

First you have to create a variable named names result so var result then you have to assign that to the function of greeting which is var result = greeting() then you are told to pass that the string of "Tom" which should be added like this var result = greeting("Tom") let me know if this helps