trpl: why (assignment == empty tuple) #26120
This commit is contained in:
parent
6c5834d81b
commit
1ece005838
@ -144,7 +144,9 @@ an expression, and a `let` can only begin a statement, not an expression.
|
||||
Note that assigning to an already-bound variable (e.g. `y = 5`) is still an
|
||||
expression, although its value is not particularly useful. Unlike other
|
||||
languages where an assignment evaluates to the assigned value (e.g. `5` in the
|
||||
previous example), in Rust the value of an assignment is an empty tuple `()`:
|
||||
previous example), in Rust the value of an assignment is an empty tuple `()`
|
||||
because the assigned value can have (just one owner)[ownership.html], and any
|
||||
other returned value would be too surprising:
|
||||
|
||||
```rust
|
||||
let mut y = 5;
|
||||
|
Loading…
x
Reference in New Issue
Block a user