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

Tony Winslow
seal-mask
.a{fill-rule:evenodd;}techdegree
Tony Winslow
iOS Development Techdegree Student 1,557 Points

I'm lost on how to complete the Tuples objectives 1-3. I don't even know where to start. Any suggestions?

no more

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

    return greeting
}
Adam Briest
Adam Briest
6,913 Points

I would suggest re-watching the videos and coding along with him in Xcode. To start you need to understand what a tuple is; a tuple allows you to return multiple items, as opposed to the original code above which only returns a single string.

As the code above sits, the -> String portion of your function states that a single string will be returned. You're going to need to modify the code to allow for the greeting function to return multiple items.

For example:

-> (String, String) would return two strings -> (Int, String) would return an integer and a string etc.

I also have Problems with this challange.

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

// Now what do i return?

// In the course Video he Returns a touple like this : var found = (true, "...") return found

// doing the same here : var tuple = (greetings, language) I get the error message "Your function needs to return a tuple

// with elements named 'greeting' and 'language'."

//return (greeting, language) also gets the same error //same goes for ("(greeting)","(language)") 

// adding language to let greeting = "Hello (Person)","(language)") and returning it also is not the correct way

//so what is askt of me ?

return greeting }

1 Answer

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

Has this been figured out yet? I'm out on a mission to chip away at the unanswered questions.