Small contribution to switch statement (#23150)
This commit is contained in:
committed by
Christopher McCormack
parent
13b93ba209
commit
63144ea2ac
@ -6,7 +6,7 @@ title: Switch Case
|
||||
|
||||
The switch statement is like a set of `if statements`.
|
||||
|
||||
It's a list of possibilities, with an action for each possibility, and an optional default action, in case nothing else evaluates to true.
|
||||
It's a list of possibilities, with an action for each possibility, and an optional default action, in case nothing else evaluates to true. Sometimes we want to compare one input to many booleans and that is when we would prefer to use a switch statement instead of an `if statement`.
|
||||
|
||||
We exit from the switch by `break`. If the `break` statement is not reached before the beginning of the next case, the execution will fall through and begin executing the code in the next case.
|
||||
|
||||
|
Reference in New Issue
Block a user