ifFunction method

  1. @DefineMethod(name: 'if')
Node ifFunction(
  1. Condition condition,
  2. Node trueValue,
  3. [Node falseValue]
)
@DefineMethod(name: 'if')

if function. Example:

a: if(not(false), 1, 2); => a: 1;
e: if(not(true), 5);     => e: ;

Implementation

@DefineMethod(name: 'if')
Node ifFunction(Condition condition, Node trueValue, [Node falseValue]) =>
    condition.eval(context).evaluated
        ? trueValue
        : (falseValue ?? Anonymous(null));