Don't put conditions in for loops... Personally, I don't like how they read. It can be non-intuitive sometimes.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Don't put conditions in for loops...
Nothing wrong with it. However, you must be aware that if the overall condition returns false, the loop ends. If you wish to skip a single iteration of the loop and continue with the next, then use only the standard condition (i.e. i < whatever) and add an if statement inside the loop for the other conditions. If that if statement returns true, then use the continue keyword. E.G.
for (int i = 0; i < someNumber; i++) {
// maybe perform some partial loop actions
if (someCondition) {
continue;
}
// perform loop action
}
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494