Simkin Switch Statement


This statement allows you to branch to different blocks of code depending on the value of an expression.

The statement has 3 main sections: an expression is given within a "switch" keyword. Then a series of "case" statements follow, each of which specifies a test expression followed by some statements to execute if the switch and case expression match.

Finally you can specify a "default" set of statements to execute.

For example:

i=0;
j=1;
switch(i){
  case j-1 {
  i=i+1;
 }
 default {
  j=j-1;
 }
}
will match the first case, and
i=i+1;
will be executed.