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 Decomposing a Tuple

I am practicing with the searchName function and it always returns false no matter what.

Here is my code:

func searchNames (#name: String) -> (found: Bool, description: String) { let names = ["Gwen","Alex","Marshall","Douglas","Carol"]

var found = (false, "\(name) is not a family member");"

for n in names {
    if n == name {
        found = (true, "\(name) is a member of the family")
    }
}

return found

}

1 Answer

Stone Preston
Stone Preston
42,016 Points

you have a syntax error here:

var found = (false, "\(name) is not a family member");"

that quote on the end might be causing some issues

Thanks