Logo

Programming-Idioms

History of Idiom 131 > diff from v35 to v36

Edit summary for version 36 by arouene:
New Cpp implementation by user [arouene]

Version 35

2019-09-26, 17:32:37

Version 36

2019-09-26, 18:08:07

Idiom #131 Successive conditions

Execute f1 if condition c1 is true, or else f2 if condition c2 is true, or else f3 if condition c3 is true.
Don't evaluate a condition when a previous condition was true.

Idiom #131 Successive conditions

Execute f1 if condition c1 is true, or else f2 if condition c2 is true, or else f3 if condition c3 is true.
Don't evaluate a condition when a previous condition was true.

Extra Keywords
else switch case
Extra Keywords
else switch case
Code
if (c1)
    f1();
else if (c2)
    f2();
else if (c3)
    f3();
Comments bubble
curly braces must be used if more than one statement follow a condition.
Demo URL
http://cpp.sh/83fiw