Skip to content

Logic Functions

Case

returns the value for the first true when-expression

Syntax:

Case(when x then y
    [when x2 then y2 ...]
    [default y3])

Examples:

Case(when 3 < 4 then "foo" default "bar") = "foo"
Case(when 3 > 4 then "foo") is null
Case(when false then 1 when true then 2) = 2

Type

returns type of argument as a string

Syntax: Type(x) -> string

Examples:

Type(7) = "int"
Type(1.5) = "float"
Type([EventTime()]) = "[time]"
Type(Bool(null)) = "bool"
Type(null) = "unknown"

And

returns the logical AND of the conditions. Handles nulls using three-valued logic

Syntax:

And(conditions: ...bool?) -> bool?

Examples:

And(true, false) is false
And(true, true) is true
And(true, null) is null
(false and null) is false
And(true, true, false) is false
And() is true

Assert

returns an error if condition is null or false

Syntax:

Assert(condition: bool?, <msg: string>) -> bool?

Examples:

Assert(3 > 4, "3 is not greater than 4") is false
Assert(null, "input is null") is null
Assert(4 > 3) is true
Assert(Contains("haystack", "needle")) is false

Bool

converts argument to a boolean value (true/false)

Syntax:

Bool(x: any) -> bool?

Examples:

Bool(0) = false
Bool(5.3) = true
Bool("") = false
Bool("False") = false
Bool(null) is null

Coalesce

returns the first non-null argument

Syntax:

Coalesce(args: ...T?) -> T?

Examples:

Coalesce(3, 4) = 3
Coalesce(null, null, 4) = 4

If

returns x if condition is true, otherwise y

Syntax:

If(condition: bool, x: T, <y: T>) -> T?

Examples:

If(false, 3) is null
If(true, 3, 4) = 3
If(false, 3, 4) = 4

IfError

returns x if there were no errors during its evaluation, otherwise returns y

Syntax:

IfError(x: T, y: T) -> T

Examples:

IfError(3, 4) = 3
IfError(0/0, 4) = 4

IfNull

returns x if it is non-null, otherwise returns y

Syntax:

IfNull(x: T?, y: T?) -> T?

Examples:

IfNull(3, 4) = 3
IfNull(null, 4) = 4

IsNull

returns whether argument is null

Syntax:

IsNull(x: any) -> bool

Examples:

IsNull(null) = true
IsNull("foo") = false
(5 is null) = false

Not

returns the logical NOT of the condition

Syntax:

Not(condition: bool) -> bool

Examples:

Not(true) = false
Not(null) is null
(not false) = true

Or

returns the logical OR of the conditions. Handles nulls using three-valued logic

Syntax:

Or(conditions: ...bool?) -> bool?

Examples:

Or(true, false) is true
Or(false, false) is false
Or(true, null) is true
(false or null) is null
Or(false, false, true) is true
Or() is false