Silly for loop syntax

I’ve been working with C-style languages for over 12 years now, but stumbled across this funny for loop syntax in a code tutorial today and had to double-take:

for (int i = 2; i --> 0;)
{
    // do something
}

Although technically correct, quite what you gain from putting the iterator within the condition apart from confusion is lost on me.

Tagged , , , , , , , ,

3 thoughts on “Silly for loop syntax

  1. jarek says:

    You get an arrow made of –>
    2 ‘–>’ 0
    2 goes to 0
    from 2 to 0

    only real hax0rz are allowed to use it though.

  2. Onur Er says:

    Lol. This looks fun too :)

    for (var I = 0; I++ < 3;)
    {
    // do something
    }

Leave a Reply

%d bloggers like this: