vendredi 27 novembre 2015

Best way to inverse if-else based on a condition

I wanted an if-else clause to behave based on an input that would leave the statements as is, or switch statements between if and else.

For example:

if (condition)
   do A;
   do B;
else
   do C;

If I have an input that indicates reverse, this should happen:

if (reverse)
   do C;
else
   do A;
   do B;

What is the best way to merge the two if-else statements above? Thanks.

Aucun commentaire:

Enregistrer un commentaire