Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Flipping variable

Name: Anonymous 2010-11-05 16:50


if(foo == 0)
    foo = 44;
else
    foo = 0;



How do I change that into a single line that does the trick using arithmetic?

Name: Anonymous 2010-11-05 17:23

>>3
Expressions are better than statements, and you should feel bad for not knowing that.

But using ternary/if requires a branch unnecessarily. The second option is neater.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List