summaryrefslogtreecommitdiff
path: root/variables/src/main.rs
diff options
context:
space:
mode:
authorJordan Gong <jordan@inspiron-n4050.localdomain>2020-08-04 18:41:09 +0800
committerJordan Gong <jordan@inspiron-n4050.localdomain>2020-08-04 18:41:09 +0800
commit6e4f0b4c6d7f7ad0eaaae5f4f2e2f3a08881ee35 (patch)
treeb73ebd8428768a403e904ca4382fed623b566010 /variables/src/main.rs
parentea8b1af82ff12a1961723b84969d2e5ad27491e9 (diff)
Play around with variables
Diffstat (limited to 'variables/src/main.rs')
-rw-r--r--variables/src/main.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/variables/src/main.rs b/variables/src/main.rs
new file mode 100644
index 0000000..3a4394a
--- /dev/null
+++ b/variables/src/main.rs
@@ -0,0 +1,16 @@
+fn main() {
+ /* mutability */
+ let mut x = 5;
+ println!("The variable of x is: {}", x);
+ x = 6;
+ println!("The variable of x is: {}", x);
+
+ /* shadowing */
+ let x = 5;
+
+ let x = x + 1;
+
+ let x = x * 2;
+
+ println!("The value of x is: {}", x);
+}