Rev Language Reference


ifelse - If-else statement as a function

If the expression is true, then the function returns the first value, otherwise the second value.

Usage

ifelse(Bool condition, Natural a, Natural b)

Arguments

condition : Bool (pass by const reference)
A variable representing the condition of the if-else statement.
a : Natural (pass by const reference)
The value if the statement is true.
b : Natural (pass by const reference)
The value if the statement is false.

Return Type

Details

The ifelse function is important when the value of a variable should deterministically change during an analysis depending on other variables. Standard if-else statements are not dynamically re-evaluated.

Example

a <- 1
b := ifelse( a == 1, 10, -10 )
b

a <- 2
b