Type Checking (is)
The is operator performs runtime type checking, returning true if the left operand matches the specified type. This enables scripts to make decisions based on the actual types of values encountered during execution.
Relational = Additive { ("<" | "<=" | ">" | ">=" | "is") Additive } ;
Type checking occurs at runtime and can be used in conditional statements to handle different data types appropriately within the same script execution path.
Valid Syntax:
if value is number then
PerformNumericOperation(value)
end
if data is object then
ProcessObjectData(data)
end
Supported Type Checks:
value is numbervalue is stringvalue is booleanvalue is objectvalue is array
Type Checking Cascade Rules:
The is operator checks the runtime type of the evaluated expression, not the literal syntax. The cascade follows this hierarchy:
null- Null values returnfalsefor all type checksnumber- Numeric values (integers and decimals), regardless of how they were createdstring- Text values enclosed in quotes or returned from string operationsboolean- The literalstrueandfalse, or results of boolean operationsarray- Collections created witharray []syntax or returned from functionsobject- Key-value structures created withobject {}syntax or returned from functions
Examples:
42 is number # true (number literal)
"42" is string # true (string literal)
"42" is number # false (string containing digits)
ToNumber("42") is number # true (converted to number)
array [1,2,3] is array # true
object {} is object # true
null is number # false
null is string # false
Scripts can change variable types at runtime by invoking standard library conversion functions (e.g., ToNumber("42") to convert string “42” to number 42).
Notes
- Type checking is performed at runtime
- The
isoperator returns a boolean value - Null values will not match any specific type