ifelse (bool c, var x, var y): var

ifelse (bool c, int x, int y): int

ifelse (bool c, string x, string y): string

Returns x when the expression or comparison c is true or nonzero, otherwise y.


c - any boolean expression.
x,y - variable, constant, or string, both of the same type.


x when c is true, otherwise y.



var a = ifelse(x > y,x,y); // a is now the maximum of x and y

See also:

abs, min, max, between, sign, clamp, if, once

► latest version online