Control Flows
In this section, we talk about how the ussd language allows you to control the flow of a program.
If-Else branching
Section titled “If-Else branching”With the help of if-else we can create two branches in our USSD flow that depends on the truthiness or falsiness of a variable.
Example USSD application branching based on whether a user entered a value or not
How If-Else affects Variable Scope
Section titled “How If-Else affects Variable Scope”Since the if block runs when the variable has a value, and the else block also runs when the variable has no value.
The compiler wouldn’t allow you to use a variable that has been checked with an if statement in its corresponding else block.
The error is shown because in that else block, the variable tool has no value. Hence, can’t be used
Going back
Section titled “Going back”coming soon!