Add documentation for else if to trpl
Adds an example of `else if` to the If section of The Rust Programming Language. r? @steveklabnik
This commit is contained in:
parent
dfc5c0f1e8
commit
cec404a066
1 changed files with 14 additions and 0 deletions
|
|
@ -34,6 +34,20 @@ if x == 5 {
|
|||
}
|
||||
```
|
||||
|
||||
If there is more than one case, use an `else if`:
|
||||
|
||||
```rust
|
||||
let x = 5;
|
||||
|
||||
if x == 5 {
|
||||
println!("x is five!");
|
||||
} else if x == 6 {
|
||||
println!("x is six!");
|
||||
} else {
|
||||
println!("x is not five or six :(");
|
||||
}
|
||||
```
|
||||
|
||||
This is all pretty standard. However, you can also do this:
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue