diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-15 18:31:41 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-15 18:42:45 +0530 |
| commit | cb0900193b9a8cd9bd48e5acacaefa3296092ecf (patch) | |
| tree | 9b6cea936edf6a7939940f4caeecd8d92edf8472 /src/doc/reference.md | |
| parent | 70647ec7c5507fc3d6ea9cbd1075e481675762c8 (diff) | |
| parent | 148d90be99b13d5874fedf398a506a5171cbba88 (diff) | |
| download | rust-cb0900193b9a8cd9bd48e5acacaefa3296092ecf.tar.gz rust-cb0900193b9a8cd9bd48e5acacaefa3296092ecf.zip | |
Rollup merge of #22307 - steveklabnik:gh14849, r=huonw
Fixes #14849
Diffstat (limited to 'src/doc/reference.md')
| -rw-r--r-- | src/doc/reference.md | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index 3e0d7dd0903..1d618052e9f 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2742,9 +2742,19 @@ items can bring new names into scopes and declared items are in scope for only the block itself. A block will execute each statement sequentially, and then execute the -expression (if given). If the final expression is omitted, the type and return -value of the block are `()`, but if it is provided, the type and return value -of the block are that of the expression itself. +expression (if given). If the block ends in a statement, its value is `()`: + +``` +let x: () = { println!("Hello."); }; +``` + +If it ends in an expression, its value and type are that of the expression: + +``` +let x: i32 = { println!("Hello."); 5 }; + +assert_eq!(5, x); +``` ### Method-call expressions |
