mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-05 09:43:31 +02:00
Add solutions to intro and variables
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Make the code print a greeting to the world.
|
||||
// TODO: Fix the code to print "Hello world!".
|
||||
|
||||
fn main() {
|
||||
printline!("Hello there!")
|
||||
printline!("Hello world!");
|
||||
}
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user