File tree Expand file tree Collapse file tree 3 files changed +6
-14
lines changed Expand file tree Collapse file tree 3 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -233,6 +233,8 @@ use-boolean-and = true
233
233
'unsafe/extern-functions.html' = ' ../unsafe-rust/unsafe-functions.html'
234
234
'unsafe/unsafe-traits.html' = ' ../unsafe-rust/unsafe-traits.html'
235
235
'exercises/day-3/safe-ffi-wrapper.html' = ' ../../unsafe-rust/exercise.html'
236
+ 'hello-world/hello-world.html' = ' ../types-and-values/hello-world.html'
237
+ 'control-flow-basics/conditionals.html' = ' if.html'
236
238
237
239
[output .exerciser ]
238
240
output-directory = " comprehensive-rust-exercises"
Original file line number Diff line number Diff line change 30
30
- [ Exercise: Fibonacci] ( types-and-values/exercise.md )
31
31
- [ Solution] ( types-and-values/solution.md )
32
32
- [ Control Flow Basics] ( control-flow-basics.md )
33
- - [ Conditionals ] ( control-flow-basics/conditionals .md )
33
+ - [ ` if ` Expressions ] ( control-flow-basics/if .md )
34
34
- [ Loops] ( control-flow-basics/loops.md )
35
35
- [ ` for ` ] ( control-flow-basics/loops/for.md )
36
36
- [ ` loop ` ] ( control-flow-basics/loops/loop.md )
Original file line number Diff line number Diff line change 2
2
minutes : 4
3
3
---
4
4
5
- # Conditionals
6
-
7
- Much of the Rust syntax will be familiar to you from C, C++ or Java:
8
-
9
- - Blocks are delimited by curly braces.
10
- - Line comments are started with ` // ` , block comments are delimited by
11
- ` /* ... */ ` .
12
- - Keywords like ` if ` and ` while ` work the same.
13
- - Variable assignment is done with ` = ` , comparison is done with ` == ` .
14
-
15
- ## ` if ` expressions
5
+ # ` if ` expressions
16
6
17
7
You use
18
8
[ ` if ` expressions] ( https://doc.rust-lang.org/reference/expressions/if-expr.html#if-expressions )
@@ -21,8 +11,8 @@ exactly like `if` statements in other languages:
21
11
``` rust,editable
22
12
fn main() {
23
13
let x = 10;
24
- if x < 20 {
25
- println!("small ");
14
+ if x == 0 {
15
+ println!("zero! ");
26
16
} else if x < 100 {
27
17
println!("biggish");
28
18
} else {
You can’t perform that action at this time.
0 commit comments