if … then … else
FEEL language construct
if condition then expression else expression
The conditional expression. Unlike an if statement in a programming language it is an expression: it always yields a value, so the else branch is mandatory. The condition must evaluate to a boolean; anything else (including null, a common cause of surprising decisions) takes the else branch.
Syntax elements
| Element | Type | Description |
|---|---|---|
| condition | boolean | the test; a non-boolean result selects the else branch |
| then | any | value if the condition is true |
| else | any | value otherwise; not optional |
Examples
if 5 > 3 then "yes" else "no"
yes
Try it ↑
if null then "a" else "b"
b
Try it ↑
if 1 > 2 then "a" else if 2 > 1 then "b" else "c"
b
Try it ↑
if {age: 34}.age >= 18 then "adult" else "minor"
adult
Try it ↑
Related constructs
null and error propagation · comparison and boolean operators
Related functions
Defined by the OMG DMN 1.6 specification, chapter 10.3 (the FEEL grammar and semantics).