diff options
| author | mo8it <mo8it@proton.me> | 2024-05-21 01:47:57 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-05-21 01:47:57 +0200 |
| commit | 0f4c42d54ea7322a4ee0ae7036c058c3061e80e9 (patch) | |
| tree | dd72045b9c25da9da24e28842ef89058d83f8647 /exercises/01_variables | |
| parent | bde2524c3b1043da489541d4885592abe16646fa (diff) | |
Add solutions to intro and variables
Diffstat (limited to 'exercises/01_variables')
| -rw-r--r-- | exercises/01_variables/variables1.rs | 6 | ||||
| -rw-r--r-- | exercises/01_variables/variables2.rs | 2 | ||||
| -rw-r--r-- | exercises/01_variables/variables3.rs | 4 | ||||
| -rw-r--r-- | exercises/01_variables/variables4.rs | 9 | ||||
| -rw-r--r-- | exercises/01_variables/variables5.rs | 10 | ||||
| -rw-r--r-- | exercises/01_variables/variables6.rs | 4 |
6 files changed, 23 insertions, 12 deletions
diff --git a/exercises/01_variables/variables1.rs b/exercises/01_variables/variables1.rs index 3035bfa..0a9e554 100644 --- a/exercises/01_variables/variables1.rs +++ b/exercises/01_variables/variables1.rs @@ -1,6 +1,6 @@ -// Make me compile! - fn main() { + // TODO: Add missing keyword. x = 5; - println!("x has the value {}", x); + + println!("x has the value {x}"); } diff --git a/exercises/01_variables/variables2.rs b/exercises/01_variables/variables2.rs index ce2dd85..e2a3603 100644 --- a/exercises/01_variables/variables2.rs +++ b/exercises/01_variables/variables2.rs @@ -1,5 +1,7 @@ fn main() { + // TODO: Change the line below to fix the compiler error. let x; + if x == 10 { println!("x is ten!"); } else { diff --git a/exercises/01_variables/variables3.rs b/exercises/01_variables/variables3.rs index 488385b..06f35bb 100644 --- a/exercises/01_variables/variables3.rs +++ b/exercises/01_variables/variables3.rs @@ -1,4 +1,6 @@ fn main() { + // TODO: Change the line below to fix the compiler error. let x: i32; - println!("Number {}", x); + + println!("Number {x}"); } diff --git a/exercises/01_variables/variables4.rs b/exercises/01_variables/variables4.rs index 67be127..8634ceb 100644 --- a/exercises/01_variables/variables4.rs +++ b/exercises/01_variables/variables4.rs @@ -1,6 +1,9 @@ +// TODO: Fix the compiler error. + fn main() { let x = 3; - println!("Number {}", x); - x = 5; // don't change this line - println!("Number {}", x); + println!("Number {x}"); + + x = 5; // Don't change this line + println!("Number {x}"); } diff --git a/exercises/01_variables/variables5.rs b/exercises/01_variables/variables5.rs index 3a74541..73f655e 100644 --- a/exercises/01_variables/variables5.rs +++ b/exercises/01_variables/variables5.rs @@ -1,6 +1,8 @@ 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 - println!("Number plus two is : {}", number + 2); + let number = "T-H-R-E-E"; // Don't change this line + println!("Spell a number: {}", number); + + // TODO: Fix the compiler error by changing the line below without renaming the the variable. + number = 3; + println!("Number plus two is: {}", number + 2); } diff --git a/exercises/01_variables/variables6.rs b/exercises/01_variables/variables6.rs index 4746331..4a040fd 100644 --- a/exercises/01_variables/variables6.rs +++ b/exercises/01_variables/variables6.rs @@ -1,4 +1,6 @@ +// TODO: Change the line below to fix the compiler error. const NUMBER = 3; + fn main() { - println!("Number {}", NUMBER); + println!("Number: {NUMBER}"); } |
