if-else(number)

xod/core/if-else(number)

Outputs either input value depending on condition
if-else(number)
@/if-else(number)
Deprecated: Use the generic `xod/core/if-else` instead
Outputs either input value depending on condition
CONDboolean
Condition value
Tnumber
Value to be output if condition is true
Fnumber
Value to be output if condition is false
if-else(number)
R
COND
T
F
Rnumber
Outputs value of `T` if `COND` is true, and `F` otherwise

C++ implementation

#pragma XOD dirtieness disable

node {
    void evaluate(Context ctx) {
        auto cond = getValue<input_COND>(ctx);
        auto trueVal = getValue<input_T>(ctx);
        auto falseVal = getValue<input_F>(ctx);
        emitValue<output_R>(ctx, cond ? trueVal : falseVal);
    }
}

Tabular tests

CONDTFR
false0.51.251.25
false102020
true102010