mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-02-02 23:38:41 +08: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:
parent
679475e784
commit
5b94ec1bb6
@ -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:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user