mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 19:34:32 -06:00
Add a reference now that ownership discusses scope
This now isn't the first time you should have seen this if you're reading in order.
This commit is contained in:
@@ -209,9 +209,9 @@ Using `mut`, we change the value that `x` binds to from `5` to `6`.
|
||||
|
||||
### Variable Binding Scope
|
||||
|
||||
Another important thing to know about variable bindings is that they are only
|
||||
valid as long as they are *in scope*. That scope begins at the point where the
|
||||
binding is declared, and ends with the curly brace that closes the block of
|
||||
As we discussed in the ownership section of Chapter XX, variable bindings are
|
||||
only valid as long as they are *in scope*. That scope begins at the point where
|
||||
the binding is declared and ends with the curly brace that closes the block of
|
||||
code containing that binding. We cannot access bindings "before they come into
|
||||
scope" or "after they go out of scope." Here’s an example to illustrate this:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user