News for hackers. Stuff that matters.
Re:Strangest Language Features by edanm on Thursday December 15, 2011 @01:29PM (#3357292)
I love the first answer to that question. And not just because I wrote it :)

A little bit of C trivia:

In C, arrays can be indexed like so:

a[10] which is very common.

However, the lesser known form (which really does work!) is:

10[a] which means the same as the above.

Re:Strangest Language Features by cjensen on Thursday December 15, 2011 @03:39PM (#3357830)
To be clear, it works because X[Y] is a synonym for * (X + Y)

Since addition is commutative, * (X + Y) can be rewritten as * (Y + X) which is a synonym for... Y[X]

Re:Strangest Language Features by djcb on Thursday December 15, 2011 @02:57PM (#3357641)
similarly, the 'approaches' pseudo-operator:

while (i --> 0) { /* do something */ }

Re:Strangest Language Features by repsilat on Friday December 16, 2011 @01:21AM (#3359708)
For some variety, there's also the left-handed "goes to" operator.

    while (5 <-- x) {} //omits the zero
and the much easier to type

    while (x --- 0) {} //equivalent to the "-->" operator