Shadowing
A new let with the same name shadows the old one and may change the type.
Example
fn main() {
let x = 5;
let x = x * 2;
let x = format!("value {}", x);
println!("{}", x);
}Result
value 10
Exercise
Redeclare.
let x = "a"; x = 1;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.