Logo

Programming-Idioms

History of Idiom 131 > diff from v20 to v21

Edit summary for version 21 by Debaran:
[Rust] Added explanation, fixed parens

Version 20

2019-02-02, 03:44:36

Version 21

2019-02-02, 03:47:29

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 }
Code
if c1 { f1() } else if c2 { f2() } else if c3 { f3() }
Comments bubble
Using if and else