3. Default value operation

As told in JavaScript variables resolution section, nexl expression will be evaluated to undefined value if variable you are trying to resolve is not declared.
The default value operation allows to apply a default followed by @ character in nexl expression when the current value in the operations chain is undefined.

For example:
In this expression we are trying to resolve a distanceToTheMoon JavaScript variable.
If this variable is not declared nexl will apply a "384400" default string value.
If this variable is declared a default value operation will be ignored.

Default value is always of a string type ( no quotes needed in nexl expression ). But you can cast easily cast it to the number or boolean ( see Type casting operation section )

Default value operation will be always applied in the following expression:
${@hello world}
This expression equals to the "hello word" JavaScript string value.

The following expression equals to empty string ( because there is not characters followed by @ sign ):

Characters followed by the @ sign are treated as default value string.
If this string contains the following characters they must be escaped, otherwise they will be treated as nexl operations:
~ ! @ # $ % ^ & * - + ? < >
${@1 \+ 2 \= 3}
This expression equals to the "1 + 2 = 3" string.

Additionally you can use nested expression instead of string followed by @ character.
Let's consider the example:
If distanceToTheMoon variable is not declared, nexl will apply the ${myDefaultValue} expression as a default value.

You can also to combine nested nexl expression(s) and hard coded strings as a default value.
For example:
${distanceToTheMoon@Distance to the moon is ${x} km}
In this case the default value is a "Distance to the moon is ${x} km" string. The ${x} nexl expression will be evaluated and substituted into the whole string.

You can also apply multiple default values in a chain:
${distanceToTheMoon@${dist1}@${myDist}@384,400 km}
Here we have 2 possible default values as nexl expression: ${dist1} and ${myDist}. nexl engine will try to evaluate each one sequentially from the left to the right. If both equal to undefined value, nexl will apply the third one default value which is "384,400 km" string.

Watch a demo