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 trialval
585 PointsWhy must println and index++ be on new lines for the code to work?
I'm total new to programming. I did this task in Xcode and no result appeared in the assist. editor until I pressed enter and moved the index++down to a new line in Xcode. The video left out the fact that if I want to write this code in one single line I must separate the index++ with " ; "or i have to write index++ on a different line. Xcode states "Consecutive statements on a line must be separated by ; " or written on a different line. Can you explain why? Code example: Doesn't work: var index = 0 while index <numbers.count{println(numbers[index])index++} Does: var index = 0 1.while index < numbers.count{println(numbers[index]);index++} 2.var index = 0 while index < numbers.count {println(numbers[index]) index++} (Index is one line down)