if-then-else
Description
If-then-else expressions almost resemble normal, spoken English. You use them to tell atfinity that if a condition is met then do this, else do that.
The expression can also contain as many elif condition then expression parts as you like. The expression closes with the keyword end.
The if-then-else expression is most often used dealing with calculated information.
Syntax
if [condition] then
[expression]
elif [condition] then
[expression]
else
[expression]
endconditionneeds to evaluate to true or false. It could be a comparison (p.age >= 18) or a boolean yes/no question (p.has_insurance).Both expressions have to return the same type of value, for example a number.
Example
To determine the risk level of a person, inquire whether it is true or false that the person loves danger.
True: the expression returns what's behind
then: the person is deemed of high risk level.False: the expression returns what's behind
else: the person's risk level is marked as low.
Example with elif
Last updated
Was this helpful?
