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 trialJun Da Ma
2,266 Pointsfor the while loop eg. why is it that if index ++ is written on the same line as println, then the code will not work
Is it becaues the syntax requirement is such that each statement has to be written on a new line?
2 Answers
Dennis Parussini
Treehouse Project ReviewerEasy, each code statement has to start on a new line. You can write multiple statements on one line, seperated by a ; but I wouldn't recommend that as your code will get unreadable over time.
Ethan Fine
2,414 PointsThis is what I made my while statement look like, and works perfectly, since index is being incremented AFTER 'println()' is executed since I am incrementing as a suffix:
while index < todo.count {
println(todo[index++])
}
Ricardo Hill-Henry
38,442 PointsRicardo Hill-Henry
38,442 PointsCan you post the code you're talking about?