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!

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

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!