hello, The instructions for fcc 4 do not work.
Task: Within the main function, declare a new variable, and name it firstName and give it a value of "<your_name>". Ensure to declare it before the println! call, and place your name within double quotes.
my code so far
fn main() {
let firstName = "<your_name>";
println!("Hello, world!");
}
outputs this:
Compiling fcc-rust-in-replit v0.1.0 (/home/runner/Rust-in-Replit)
warning: unused variable: `firstName`
--> calculator/src/main.rs:2:7
|
2 | let firstName = "<your_name>";
| ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_firstName`
|
= note: `#[warn(unused_variables)]` on by default
warning: variable `firstName` should have a snake case name
--> calculator/src/main.rs:2:7
|
2 | let firstName = "<your_name>";
| ^^^^^^^^^ help: convert the identifier to snake case: `first_name`
|
= note: `#[warn(non_snake_case)]` on by default
warning: `fcc-rust-in-replit` (bin "calculator") generated 2 warnings
Finished dev [unoptimized + debuginfo] target(s) in 0.70s
Running `target/debug/calculator`
Hello, world!
so I also try the suggested:let _firstName = "<your_name>";
which gives me more trouble:
cargo run --bin calculator
Compiling fcc-rust-in-replit v0.1.0 (/home/runner/Rust-in-Replit)
warning: variable `_firstName` should have a snake case name
--> calculator/src/main.rs:2:7
|
2 | let _firstName = "<your_name>";
| ^^^^^^^^^^ help: convert the identifier to snake case: `_first_name`
|
= note: `#[warn(non_snake_case)]` on by default
warning: `fcc-rust-in-replit` (bin "calculator") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.73s
Running `target/debug/calculator`
Hello, world!
The instructions say to declare a new variable(before the println call) and name it firstName and then give it a value of “<your_name>”, which I did. and then place your name within double quotes(but it does not say where to put that).
I decided to try:
fn main() {
let firstName = "Myname";
println!("Hello, world!");
}
which then outputs this:
warning: unused variable: `firstName`
--> calculator/src/main.rs:2:7
|
2 | let firstName = "Myname";
| ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_firstName`
|
= note: `#[warn(unused_variables)]` on by default
warning: variable `firstName` should have a snake case name
--> calculator/src/main.rs:2:7
|
2 | let firstName = "Myname";
| ^^^^^^^^^ help: convert the identifier to snake case: `first_name`
|
= note: `#[warn(non_snake_case)]` on by default
warning: `fcc-rust-in-replit` (bin "calculator") generated 2 warnings
I then tried the suggested fix:
fn main() {
let first_name = "Myname";
println!("Hello, world!");
}
which outputs this:
Compiling fcc-rust-in-replit v0.1.0 (/home/runner/Rust-in-Replit)
warning: unused variable: `first_name`
--> calculator/src/main.rs:2:7
|
2 | let first_name = "Myname";
| ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_first_name`
|
= note: `#[warn(unused_variables)]` on by default
warning: `fcc-rust-in-replit` (bin "calculator") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.58s
Running `target/debug/calculator`
Hello, world!
seems like we’re getting somewhere, right?
so then I tried this:
fn main() {
let first_name = "Myname";
println!("Hello, ", first_name, "!");
}
and this:
fn main() {
let first_name = "Myname";
println!("Hello, " + first_name, + "!");
}
The output tells me it expected , instead of + which is what I had just tried…
fn main() {
let first_name = "Myname";
println!("Hello, first_name !");
}
I have tried running fcc test 4, which gives me the same information, so matter what the code is.
Even though both of those conditions are satisfied already, it always reminds me to:
You should declare a variable `firstName` and give it a value of your first name within double quotes.
You should follow the compiler's advice to add a semi-colon at the end.
In a failed attempt to get some helpful output, I have tried adding a semicolon in a couple different places to no avail.
warns me about unused variables again, as expected.
So what gives? isn’t this supposed to be a beginner friendly tutorial here? obviously something is not clear.
