NAME

switch - Complicated conditional statement

SYNTAX

switch( expression )
{
case constant1:
statement1

case constant2:
statement2
break;

case constant3..constant4:
statement4
break;

default:
statement3
}

DESCRIPTION

Switch evaluates the expression give and then executes one or more statement accordingly to the result. If the result is equal to constant1 then statement1 will be executed, please observe that the second case-statement dos _not_ abort the execution in any way instead statement2 will also be executed. After that break will cause execution to continue after the after the last } in the switch statement. If the result is equal to constant2 only statement2 will be executed. If expression <= consant3 and expression >= constant4, statement4 will be executed. In all other cases statement3 is executed because it is 'default'. Please note that the expression and constants can be any type that can be written as a constant. Arrays, mappings and lists have little or no use though.

KEYWORDS

control

SEE ALSO

if-else and break