Skip to main content

Variables

Syntax rules

For the full set of variable / identifier / assignment rules, see Syntax & Grammar.

A variable is a named reference to a value. Assigning a value the first time both declares and initialises the variable.

Variable declaration#

<var_name> = <value>;

Rules:

  • Identifier pattern: [a-zA-Z_][a-zA-Z_0-9]* — must start with a letter or underscore.
  • No type prefix inside the function body. The type is auto-detected from the assigned value. Types are only allowed on the function signature.
  • The value can be a literal, an expression, or another variable.
// WRONG — type prefix in bodyString name = "Asset";Number count = 10;
// RIGHTname = "Asset";count = 10;

Assignment forms#

Three left-hand-side (LHS) forms are supported:

// 1. Simple variablename = "Asset";
// 2. Bracket access (key is any expression)data["title"] = "Inspection";items[0] = "first";
// 3. Dotted access (multi-level)record.priority.name = "High";

Reserved keywords#

The following words are reserved and cannot be used as variable names:

CategoryReserved words
Typesvoid, String, Number, Boolean, Map, List, Criteria, Object
Control flowif, else, for each, in, return, try, catch
Literalstrue, false, null
Operatorsnew
Special atomsModule, Reading, Calender, Clock
Statement keywordslog
DB-param keyscriteria, fieldCriteria, field, aggregation, limit, range, groupBy, orderBy, asc, desc, to