vault backup: 2025-05-14 16:08:22
This commit is contained in:
parent
3ee80994dc
commit
baa7139462
@ -166,3 +166,20 @@ I can use this multiple line comment */
|
|||||||
```
|
```
|
||||||
|
|
||||||
# 3.5 Control Flow
|
# 3.5 Control Flow
|
||||||
|
## `if` Statements
|
||||||
|
If statements in Rust are expressions, that optionally have else and else if
|
||||||
|
statements.
|
||||||
|
|
||||||
|
```Rust
|
||||||
|
if number > 5 {
|
||||||
|
println!("Yay!")
|
||||||
|
} else if number < 4{
|
||||||
|
println!("Boo!")
|
||||||
|
} else {
|
||||||
|
println!("Just right!")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Conditions for if statements *must* return Boolean types.
|
||||||
|
|
||||||
|
## Repetition with Loops
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user