5 ms·
What's going on here? https://github.com/jstimpfle/tetris-on-a-plane/blob/master/tetris.js#L93 https://github.com/jstimpfle/tetris-on-a-plane/blob/master/t...
by wmichelin 10y ago
What's going on here? https://github.com/jstimpfle/tetris-on-a-plane/blob/master/tetris.js#L93 https://github.com/jstimpfle/tetris-on-a-plane/blob/master/t...
- jstimpfle 10y agoLink broke with new commit, here's a stable one: https://github.com/jstimpfle/tetris-on-a-plane/blob/d5d4d821aed95d9f1618f410ddca3b6b8b2c8853/tetris.js#L101 https://github.com/jstimpfle/tetris-on-a-plane/blob/d5d4d821... This is a test to see how quickly someone brings up the stackoverflow link ;-)
- proto-n 10y agohttp://stackoverflow.com/questions/1642028/what-is-the-name-of-the-operator-in-c http://stackoverflow.com/questions/1642028/what-is-the-name-...
- Cpoll 10y agoIn other words, it's a crappy way to write `i-- > 0` Note that it's not logically equivalent to `for (var i = 5; i > 0; i--)` because in this case the `i--` operation is applied after the body of the loop. Try it in your browser: for (var i = 5; i-- > 0;) { console.log(i); } //4,3,2,1 for (var i = 5; i > 0; i--) { console.log(i); } //5,4,3,2,1
- jstimpfle 10y agoThis is why I actually like this syntax (and get fun out of provoking "shudder" comments). - Can use the same limits as in ascending iteration - Can do decrementing in for loop (no extra line) - The arrow unambiguously signals that the iteration is correct :-)
- bbcbasic 10y ago!!"It's the JS way"
- deleted 10y ago[deleted]
- Sophistifunk 10y ago"Clever" code. shudder It's confusing to read for anybody not used to it, particularly as you need to set the "initial" value to the "actual initial value"+1.