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.
Parameters:
c - any boolean expression.
x,y - variable, constant, or
string, both of the same type.
Returns:
x when c is true, otherwise y.
Remarks:
- Functions should not be used for x and y, since function parameters are always executed when ifelse is called, regardless of the state of c. Use if for executing functions dependent on an expression.
Example:
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