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 Basics (retired) Control Flow While and Do-While Loop

Tarek Borhan El-Din
Tarek Borhan El-Din
4,229 Points

Something is wrong in the video

First of all, I am not completely new to programming, I have some basic knowledge.

So, why is there an error when Amit wrote index++ before the println() function? It begins with index[1], but the println function should still be executed because the code gets read from top to bottom.

1 Answer

Actually, it did run. If you can see the console from screenshot, the while loop executed 4 times before giving an error on the 5th iteration.

Imgur

Tarek Borhan El-Din
Tarek Borhan El-Din
4,229 Points

Oh, you're right, didnt notice that. Thank you! :)