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

Why using 2x "found"?

I am confused by using "Found" in two different ways.

within the function "found" ist used to store the whole tuple, i.e. either (true, "(name) ist a Treehouse Teacher") or (false, "(name) ist not a Treehouse Teacher")

outside the function, however, "found" is to be used as only the boolean value of the tuple.

For me that is highly confusing why to use the same variable name for two different things. Or am I missing a point here?

1 Answer

Marissa Amaya
Marissa Amaya
11,782 Points

No, in fact you hit the nail on the head. In practice, you would want the local variable in searchNames to be something like "foundName". And then when applying labels, you'd want it to read like (isFound: Bool, description: String).