diff options
Diffstat (limited to 'rust/theBook/chapter-3-variables-and-mutability/control-if/src/main.rs')
-rw-r--r-- | rust/theBook/chapter-3-variables-and-mutability/control-if/src/main.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/rust/theBook/chapter-3-variables-and-mutability/control-if/src/main.rs b/rust/theBook/chapter-3-variables-and-mutability/control-if/src/main.rs new file mode 100644 index 0000000..8866444 --- /dev/null +++ b/rust/theBook/chapter-3-variables-and-mutability/control-if/src/main.rs @@ -0,0 +1,19 @@ +fn main() { + let number = 3; + + if number < 5 { + println!("number is less than 5"); + } else { + println!("number is bigger than 5"); + } + + let use_let = if number < 5 {number} else {5}; + + println!("number is {use_let}"); + + println!("number is {}", if number < 5 {4} else {6}); + + let names = ["name", "is", "idiot"]; + + println!("names: {:?}",names); +} |