Default value expression

Syntax

expression ? defaultValue

where:

Description

This construct handles the default value to use in case an expression returns null.

First the main expression is evaluated. If it is not null, the evaluated value is returned (and the default value is ignored). If the expression evaluates to null, then this construct returns the evaluation result of the default value expression.

This construct is related to the null management in dotted notation.

Examples

// Returns the string "unnamed" for any untyped attribute
myAttr.type.name.toUppercase() ? "Unnamed"