- Views: 1
- Report Article
- Articles
- Writing
- Article Marketing
What is Control Flow in Rust?
by Mansoor Ahmed
Posted: Oct 24, 2020
Posted: Oct 24, 2020
A control flow is the order in which the piece of program is executed.
In control flow we have following expressions:
- If expression
- Else expression
- Else if expression
If Expression:
If expression allows to branch your code to any condition.
If the condition is true then the program in if block will be executed.
When if expression is not true then the program will be passed to further blocks of else if expressions or else expression.
The curly brackets defining the program blocks are called arms.
Else Expression:
Else expression gives the program an alternative block of code to execute when the condition introduced in if block evaluates to false.
Else expression comes at last.
Example
fn main() {
let number = 3;
if number
Mansoor Ahmed Chemical Engineer,Web developer