Conditional
#
Ternary conditionSymbol: ?
Usually takes 3 parameters: condition, true branch expression and false branch expression.
Example:
If you pass this operator with only 2 parameters the third one is undefined
:
#
Condition with returnSymbol: ?!
Takes 2+ parameters: condition and returnable true branch expression.
Returnable conditional operator ?!
is used in sync/async functions and sync/async computations to return value by some condition.
E.g., the following code in function will return "One"
if number
equals 1
:
This operator can have multiline returnable block:
Operator ?!
can't be used as the last or single operator of any block. The folling example shows WRONG usage.