Wednesday, December 19, 2012

Code Oddity: Conditionally starting

I'm starting to see a lot of these:
 
for(int x=0; x < someLimit; x++ ){
     if (x == 0 ) {
       // do initialization
     }
     else {
       // do everything else
     }
}
Is it just me, or is this a pretty weird thing to see? I've seen it a half-dozen times in the past few months and I don't think (outside of Duff's device) I've seen a switch/case or if/else on the loop counter in years.