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 Tuples

Why did the playground output .0 and .1 ?

In the video you told us that the .0 and .1 in the playground represent the tuple values but you didn't tell us why the playground does that. So why does it? Can you have three values in a tuple? Would the playground output .0,.1 and .2 if there were three values? Do all IDEs do this?

1 Answer

J.D. Sandifer
J.D. Sandifer
18,813 Points

Here are your answers in order:

  • The playground responds to the .0 and .1 tuple part references because they are built into the swift language.
  • Tuples can be any size, that's why they're tuples and not just doubles or duples.
  • So yes, three values in a tuple is totally possible.
  • .0, .1 and .2 would work if there were three values.
  • Yes, all IDE's should work with the .0, etc. because it's part of the Swift language, not just the IDE.

Good question!