diff options
| author | Carol (Nichols || Goulding) <carol.nichols@gmail.com> | 2015-09-16 20:19:24 -0400 |
|---|---|---|
| committer | Carol (Nichols || Goulding) <carol.nichols@gmail.com> | 2015-09-16 20:27:45 -0400 |
| commit | f4c6dcf1d7c8c95bed0d7be36f27f504d8c0cb87 (patch) | |
| tree | 5224716db1cd7a2d1711b16902e45c5f5189a7ec /variables | |
| parent | 32900581b9428a091078e78e1895e7448a70a710 (diff) | |
Add some exercises about variables!
Diffstat (limited to 'variables')
| -rw-r--r-- | variables/variables1.rs | 6 | ||||
| -rw-r--r-- | variables/variables2.rs | 10 | ||||
| -rw-r--r-- | variables/variables3.rs | 8 | ||||
| -rw-r--r-- | variables/variables4.rs | 6 |
4 files changed, 30 insertions, 0 deletions
diff --git a/variables/variables1.rs b/variables/variables1.rs new file mode 100644 index 0000000..3035bfa --- /dev/null +++ b/variables/variables1.rs @@ -0,0 +1,6 @@ +// Make me compile! + +fn main() { + x = 5; + println!("x has the value {}", x); +} diff --git a/variables/variables2.rs b/variables/variables2.rs new file mode 100644 index 0000000..9368488 --- /dev/null +++ b/variables/variables2.rs @@ -0,0 +1,10 @@ +// Make me compile! + +fn main() { + let x; + if x == 10 { + println!("Ten!"); + } else { + println!("Not ten!"); + } +} diff --git a/variables/variables3.rs b/variables/variables3.rs new file mode 100644 index 0000000..cadb40b --- /dev/null +++ b/variables/variables3.rs @@ -0,0 +1,8 @@ +// Make me compile! + +fn main() { + let x = 3; + println!("Number {}", x); + x = 5; + println!("Number {}", x); +} diff --git a/variables/variables4.rs b/variables/variables4.rs new file mode 100644 index 0000000..c9a63f5 --- /dev/null +++ b/variables/variables4.rs @@ -0,0 +1,6 @@ +// Make me compile! + +fn main() { + let x: i32; + println!("Number {}", x); +} |
