Logo

Programming-Idioms

History of Idiom 131 > diff from v18 to v19

Edit summary for version 19 by 1.7.4:
New JS implementation by user [1.7.4]

Version 18

2017-11-23, 10:28:20

Version 19

2019-01-24, 12:42:20

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
c1 ? f1 : c2 ? f2 : f3
Comments bubble
The ternary operator is great for conciseness and statement-freedom.
It's not so great for clarity.
Oh well. \(^w^)/