Complete variables challenge

This commit is contained in:
Suzie Kim 2024-01-31 10:09:11 -05:00
parent c440da8963
commit 69b6d2116b
No known key found for this signature in database
GPG key ID: 83C4CC3808F9AAE9
6 changed files with 12 additions and 14 deletions

View file

@ -5,9 +5,8 @@
// Execute `rustlings hint variables1` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
x = 5;
let x = 5;
println!("x has the value {}", x);
}

View file

@ -3,10 +3,9 @@
// Execute `rustlings hint variables2` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
let x;
let x = 10;
if x == 10 {
println!("x is ten!");
} else {

View file

@ -3,9 +3,9 @@
// Execute `rustlings hint variables3` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
let x: i32;
let x: i32; //giving it a type
x = 3; //assigning a value
println!("Number {}", x);
}

View file

@ -3,10 +3,9 @@
// Execute `rustlings hint variables4` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
let x = 3;
let mut x = 3;
println!("Number {}", x);
x = 5; // don't change this line
println!("Number {}", x);

View file

@ -3,11 +3,14 @@
// Execute `rustlings hint variables5` or use the `hint` watch subcommand for 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; // don't rename this variable
let number = 3; // don't rename this variable
println!("Number plus two is : {}", number + 2);
// This is shadowing. The compiler will see the second let
// aka the "shadow". It will overwrite the first unless it's "shadowed"
// or the scope ends.
// You will get a compile error if you try to
}

View file

@ -3,9 +3,7 @@
// Execute `rustlings hint variables6` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
const NUMBER = 3;
const NUMBER: i32 = 3;
fn main() {
println!("Number {}", NUMBER);
}