if

The if keyword executes one of two statement blocks.

Purpose

This statement is used for executing one of two statement blocks in the action part of rules or in functions.

Syntax

if (test) {statement} 
[else {statement}] 

Description

The test can be any valid test, as in the Java™ programming language. If the test returns true, the first statement block is executed and the else block is skipped over. If the test returns false, the first block is skipped over and the statement block following the else keyword is executed. Any ARL statement can be executed within the statement block, as well as arithmetic expressions and method calls. A statement block consists of one or more statements. A single statement does not require the braces ({}). The else keyword and its statement block are optional.

Example

if (a.contains(b)) {
   note("a contains " + b);	
}