Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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).