14

I hate myself so much right now. I just spent an hour finding the bug in the following:

var counter=0
while(1){
if(counter%2==0){
doStuff()
counter++
}
}

Because I thought it was a bug in doStuff().

Comments
  • 1
    So, what's the highest number of loops it ran before you interferred?
  • 2
    Spotted it after like a minute. Did wonder if it was operator precedence though.
  • 0
    Also assuming this is JS, there's probably a library with 38 zillion downloads to do exactly what you're trying. With little LOC improvement once you count the import statements.
  • 0
    This is python, right?
  • 1
    @arazzz Lots. This was in Screeps and the while loop was really module.exports.loop, so it ran once a tick and the only sign of it was that doStuff() didn't change something it was supposed to after the first run.
  • 4
    @Conrad python and brackets? Are you mad? Also no incrementation in python. Good old fashioned += 1 only.
  • 2
    @Conrad what @radekwlsk said, plus 'var'
  • 0
    @electrineer type hints are actually possible in Python now, but still no 'var' type
Add Comment