book icon indicating copy to clipboard operation
book copied to clipboard

Clarify shadowing sentence.

Open olingern opened this issue 2 years ago • 1 comments

The other difference between mut and shadowing is that because we’re effectively creating a new variable when we use the let keyword again, we can change the type of the value but reuse the same name. For example, say our program asks a user to show how many spaces

It took me a couple of times reading this and the examples below, but I believe the desired conjunction is and here.

olingern avatar Nov 18 '22 19:11 olingern

On second thought, maybe the intent of the sentence is more to contrast with mut?

Maybe something like:

When using mut we lose immutability which is something we not might always want. By using let, we can both change the value and type and maintain immutability after our transformations are complete. This also allows us to signal the intent of variable usage.

olingern avatar Nov 18 '22 19:11 olingern