mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-10 12:49:18 +00:00
test2
This commit is contained in:
parent
0da122248e
commit
e282e897d2
@ -1,9 +0,0 @@
|
|||||||
# Variables
|
|
||||||
|
|
||||||
In Rust, variables are immutable by default.
|
|
||||||
When a variable is immutable, once a value is bound to a name, you can’t change that value.
|
|
||||||
You can make them mutable by adding mut in front of the variable name.
|
|
||||||
|
|
||||||
## Further information
|
|
||||||
|
|
||||||
- [Variables and Mutability](https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html)
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
// variables1.rs
|
|
||||||
// Make me compile! Execute the command `rustlings hint variables1` if you want a hint :)
|
|
||||||
|
|
||||||
// About this `I AM NOT DONE` thing:
|
|
||||||
// We sometimes encourage you to keep trying things on a given exercise,
|
|
||||||
// even after you already figured it out. If you got everything working and
|
|
||||||
// feel ready for the next exercise, remove the `I AM NOT DONE` comment below.
|
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x = 5;
|
|
||||||
println!("x has the value {}", x);
|
|
||||||
}
|
|
||||||
Binary file not shown.
@ -1,14 +0,0 @@
|
|||||||
// variables2.rs
|
|
||||||
// Make me compile! Execute the command `rustlings hint variables2` if you want a hint :)
|
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x;
|
|
||||||
x=9;
|
|
||||||
if x == 10 {
|
|
||||||
println!("Ten!");
|
|
||||||
} else {
|
|
||||||
println!("Not ten!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
// variables3.rs
|
|
||||||
// Make me compile! Execute the command `rustlings hint variables3` if you want a hint :)
|
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x = 3;
|
|
||||||
println!("Number {}", x);
|
|
||||||
x = 5; // don't change this line
|
|
||||||
println!("Number {}", x);
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
// variables4.rs
|
|
||||||
// Make me compile! Execute the command `rustlings hint variables4` if you want a hint :)
|
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x: i32;
|
|
||||||
println!("Number {}", x);
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
// variables5.rs
|
|
||||||
// Make me compile! Execute the command `rustlings hint variables5` if you want a hint :)
|
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let number = "T-H-R-E-E"; // don't change this line
|
|
||||||
println!("Spell a Number : {}", number);
|
|
||||||
number = 3;
|
|
||||||
println!("Number plus two is : {}", number + 2);
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
// variables6.rs
|
|
||||||
// Make me compile! Execute the command `rustlings hint variables6` if you want a hint :)
|
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
const NUMBER = 3;
|
|
||||||
fn main() {
|
|
||||||
println!("Number {}", NUMBER);
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user