Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One of the more common examples is if you need to iterate backwards. It's awkward because the [0,N) interval becomes (N,0].

for(i=N-1; i>=0; i--)



Notably, this requires you to use a signed index type, which is absurd.

The alternative is to use the so-called goes-to operator: for (i=N; i --> 0;). But this actually relies on the postincrement semantics, which is a huge wart.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: