Almost Correct: Assignment
Explore how Rust handles variable assignment with a focus on mutability. Learn why variables are immutable by default and how to modify declarations to enable reassignment. Understand this key concept to write clearer, more manageable Rust code and avoid common errors with variable assignment.
We'll cover the following...
We'll cover the following...
A let statement defines a new variable. What if we did the same let keep_going = false;, but without the let? In other words, what if our program looks like this:
This is close, but no cigar. Rust complains with the following error message:
error[E0384]: ...