Do you use i-->0 for backward loops?
- by maaartinus
Some people write
for (int i=N; i-->0; ) doSomething(i);
instead of
for (int i=N-1; i>=0; --i) doSomething(i);
for backward loops. The --> "operator"1 looks very confusing at the first glance, but it's trivial:
i-->0 simply parses as (i--)>0, and once you get it, you see it immediately.
The main disadvantage is the strange look. The advantage is that you'll get it always right (unlike the more verbose version offering the possibility to forget something, which really happened to me a couple of times).
What do you think about using the --> "operator"?
1First time I saw the funny term in a comment to this question today.