Statements: fallthrough

The fallthrough statement passes the control to the next case or to the default clause within a switch-case statement.




In Chora the switch-case statement executes only the matching case clause and exits thereupon the entire switch statement. This behavior differs from the known from languages such as C or JavaScript where the control falls through to the next clause automatically. To achieve similar effects it is necessary to use the fallthrough statement explicitly.

The fallthrough statement, when executed inside a switch, ends the execution of the actual case clause passing the control (falling through) to the next following case or default statement. The control is passed regardless of the condition associated to the case statement. Following example demonstrates the usage of the fallthrough statement:

switch ( CharCode ) { case 'A', 'B', 'C' : { trace "Upper case letter"; fallthrough; } case 'a', 'b', 'c' : { trace "A letter"; fallthrough; } default: trace "Any sign"; }