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

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


c - any boolean expression.
x,y - any var.


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

► latest version online