about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-02-22 01:46:42 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-02-22 01:46:42 +0530
commit9d650ae723499df00f5dde1ff38382d8e729285e (patch)
tree89cf61a2cabc7bb6d24e82ecbead9568186e3eca /src
parent2bb8b95cd8e73cefe69f8e4d3b013cab1e1a1301 (diff)
parentcec404a0663509c4075a08d85887ca85fa6f8dff (diff)
downloadrust-9d650ae723499df00f5dde1ff38382d8e729285e.tar.gz
rust-9d650ae723499df00f5dde1ff38382d8e729285e.zip
Rollup merge of #22515 - adamhjk:add-else-if-to-docs, r=steveklabnik
 Adds an example of `else if` to the If section of The Rust Programming
Language.

r? @steveklabnik
Diffstat (limited to 'src')
-rw-r--r--src/doc/trpl/if.md14
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: