if(predicate, then_expr, else_expr) returns then_expr if predicate is true, and else_expr otherwise.
if(predicate, then_expr, else_expr)
then_expr
predicate
true
else_expr
If predicate is exactly true , we return then_expr .
Otherwise, we return else_expr.
# evaluates to "red" if the color is red, "green" otherwise if(color_is_red, "red", "green")
Last updated 1 year ago
Was this helpful?