| Conditional Statements | ||||||||||
|
||||||||||
| if Statement | ||||||||||
syntax
if boolean_expression {
// statement(s) will execute if the boolean expression is true
}
|
||||||||||
| if...else Statement | ||||||||||
syntax
if boolean_expression {
// statement(s) will execute if the boolean expression is true
} else {
// statement(s) will execute if the boolean expression is false
}
|
||||||||||
| Nested if | ||||||||||
syntax
if boolean_expression1 {
//statements if the expression1 evaluates to true
} else if boolean_expression2 {
//statements if the expression2 evaluates to true
} else {
//statements if both expression1 and expression2 result to false
}
|
||||||||||
| match Statement | ||||||||||
syntax
let expressionResult = match variable_expression {
constant_expr1 => {
//statements;
},
constant_expr2 => {
//statements;
},
_ => {
//default
}
};
|