rearranged things
This commit is contained in:
parent
c073ab0d91
commit
cfe2547809
8 changed files with 28 additions and 22 deletions
6
examples/hello.rs
Normal file
6
examples/hello.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
// i want to hug ferris
|
||||
|
||||
fn main() {
|
||||
println!("Hello World!");
|
||||
println!("I'm a Rustacean!");
|
||||
}
|
5
examples/variables.txt
Normal file
5
examples/variables.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
- Variables are immutable by default
|
||||
- Normal variables can have their value reassigned, mutable variables must keep the same type
|
||||
and immutable variables can have their values reassigned using let again, also allowing you
|
||||
to change the type (shadowing)
|
||||
- Constant variables cannot have new variables reassigned to the name they use
|
12
examples/variables_mutable.rs
Normal file
12
examples/variables_mutable.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* x is defined as an mutable variable, the value is reassigned again later without redfining it.
|
||||
* mutable variables are assigned one type, and the variable cannot be any other type other than the
|
||||
* one it was originally assigned.
|
||||
*/
|
||||
|
||||
fn main() {
|
||||
let x = 5;
|
||||
println!("The value of x is: {}", x);
|
||||
let x = 6;
|
||||
println!("The value of x is: {}", x);
|
||||
}
|
11
examples/variables_shadow.rs
Normal file
11
examples/variables_shadow.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* x is defined as an immutable variable, then defined again later (shadowed?)
|
||||
* redefining a variable like this lets you change the type.
|
||||
*/
|
||||
|
||||
fn main() {
|
||||
let x = 5;
|
||||
println!("The value of x is: {}", x);
|
||||
let x = 6;
|
||||
println!("The value of x is: {}", x);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue