diff options
| -rw-r--r-- | src/doc/trpl/if.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/doc/trpl/if.md b/src/doc/trpl/if.md index a350df67b17..7dac49987d8 100644 --- a/src/doc/trpl/if.md +++ b/src/doc/trpl/if.md @@ -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: |
