
Syntactic sugar in C – (ab)using “for” loops - mmphosis
http://zserge.com/blog/c-for-loop-tricks.html
======
msimpson
I will never understand why these examples are considered abuse as they
exhibit standard behavior.

It's just as if I were to write the following JavaScript:

    
    
      node.classList[ isHidden ? 'add' : 'remove' ]( 'hide' );
    

I'm simply using a ternary and a bit of reflection, but the arguments
regarding "correctness" this engenders...

~~~
pouta
Can you explain a bit further what the code you posted does?

~~~
msimpson
Element.classList:

[https://developer.mozilla.org/en-
US/docs/Web/API/Element/cla...](https://developer.mozilla.org/en-
US/docs/Web/API/Element/classList)

Property Accessors (Bracket Notation):

[https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Refe...](https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Operators/Property_Accessors#Bracket_notation)

Conditional (ternary) Operator:

[https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Refe...](https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator)

