Update Examples
parent
abb1dd87d5
commit
a23e1fa400
28
Examples.md
28
Examples.md
@ -539,10 +539,38 @@ Or here.
|
|||||||
<td>
|
<td>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
fn main() {
|
||||||
|
let long_lived_binding = 1;
|
||||||
|
|
||||||
|
{
|
||||||
|
let short_lived_binding = 2;
|
||||||
|
println!("inner short: {}", short_lived_binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error! `short_lived_binding` doesn't exist in this scope
|
||||||
|
println!("outer short: {}", short_lived_binding);
|
||||||
|
// FIXME ^ Comment out this line
|
||||||
|
|
||||||
|
println!("outer long: {}", long_lived_binding);
|
||||||
|
}
|
||||||
```
|
```
|
||||||
</td><td>
|
</td><td>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
fn main
|
||||||
|
let long_lived_binding = 1
|
||||||
|
|
||||||
|
scope //! Husht needs a keyword; other choices exist
|
||||||
|
let short_lived_binding = 2
|
||||||
|
println! "inner short: {}", short_lived_binding
|
||||||
|
|
||||||
|
// Error! `short_lived_binding` doesn't exist in this scope
|
||||||
|
println! "outer short: {}", short_lived_binding
|
||||||
|
// FIXME ^ Comment out this line
|
||||||
|
|
||||||
|
println! "outer long: {}", long_lived_binding
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user