TOC Prev Next

Expressions

Null Coalescing

With null coalescing we really mean error, or bottom, coalescing. The defaults mechanism for disjunctions can also be used to provide fallback values in case an expression evaluates to bottom.

In the example the fallback values are specified for a and b in case the list index is out of bounds.

list: [ "Cat", "Mouse", "Dog" ]

a: list[0] | "None"
b: list[5] | "None"
list: [ "Cat", "Mouse", "Dog" ]

a: "Cat"
b: "None"