Skip to main content
Version: 5.x

Branching (CASE, IF, MULTI)

The branching operator creates an action that determines for a set of conditions which condition is met, and calls the corresponding action.

All conditions are defined as properties and/or parameters. Accordingly, a condition is met if the value of the property or parameter by which it is set is not equal to NULL.

Polymorphic form

This operator also allows to define a condition not explicitly but by using as a condition the signature of the action corresponding to that condition. We will call this the polymorphic form of the operator.

Mutual exclusion of conditions

The branching operator lets you specify that all its conditions are mutually exclusive. If this option is set, and the conditions are not in fact mutually exclusive, the platform will throw the corresponding error.

It is worth noting that this check is no more than a hint to the platform (for better optimization), and also a kind of self-checking on the part of the developer. However, in many cases it allows you to make the code more transparent and readable (especially with the polymorphic form of the selection operator).

Implicit definition

This operator has the capability of an implicit definition using the technique of extensions, which allows, in particular, to implement polymorphism in the form that is common practice in OOP.

Single form

The single form of the branching operator checks exactly one condition. If this condition is met, the specified action is called. It is also possible to specify an alternative action that is called if the condition is not met.


Type of mutual exclusion and implicit definition do not make sense/are not supported for this form of the operator


To declare an action implementing general form of branching, the CASE operator is used. For the single form of branching, the IF operator is used, and for the polymorphic form the MULTI operator.


caseActionTest(a) {
WHEN test(a) > 7 THEN MESSAGE '>7';
WHEN test(a) > 6 THEN MESSAGE '>6';
WHEN test(a) > 5 THEN MESSAGE '>5';
// Action that compares the value of the count property to 3 and displays a message to the user
moreThan3(obj) {
IF count(obj) > 3 THEN
MESSAGE '<=3';

checkNullName (Store st) {
IF NOT name(st) THEN
MESSAGE 'Name is null';
CLASS Shape;

CLASS Square : Shape;
CLASS Circle : Shape;

message (Square s) { MESSAGE 'Square'; }
message (Circle c) { MESSAGE 'Circle'; }

message (Shape s) = MULTI message[Square](s), message[Circle](s);