|
switch |
|
switch (value) { case a: {coding break} case b: {coding break} case c: {coding break} case d: {coding break} default: {coding} }
What the switch statement does is take value, compare it to a number of case's, if value equals a certain case then the corresponding block is executed. It is important to have the break statement included in the block because otherwise if case b is chosen, the code of case c and case d will also be executed, it is however not required. The switch statement is an alternative to a large number of if statements, it is also faster (fps wise) and easier to debug, it also makes your coding nicer to look at. There is no limit to the number of case's you can have. If none of the case's are matched then default coding is executed, it is not necessary to have a default statement.
Example:
Abyssal_Nuclei - Revision #2
|