about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexei Sholik <alcosholik@gmail.com>2013-06-08 04:02:41 +0300
committerAlexei Sholik <alcosholik@gmail.com>2013-06-08 04:10:50 +0300
commit93b2ddfc88f581a1155236c9ac79983f72b0ff46 (patch)
tree3b225a99e7b3e801aadd52d5b2dea3dd2b888d6d
parentb8cf2f8056d29423430b723acd70e525d1249a32 (diff)
A reminder that a block is a single expr in closures
This is something that's only been briefly mentioned in the beginning of
the tutorial and all of the closure examples within this subsection
include only one expression between { and }.
-rw-r--r--doc/tutorial.md13
1 files changed, 9 insertions, 4 deletions
diff --git a/doc/tutorial.md b/doc/tutorial.md
index 8caf8704e05..0066434c40c 100644
--- a/doc/tutorial.md
+++ b/doc/tutorial.md
@@ -1439,10 +1439,15 @@ call_closure_with_ten(closure);
 ~~~~
 
 Closures begin with the argument list between vertical bars and are followed by
-a single expression. The types of the arguments are generally omitted,
-as is the return type, because the compiler can almost always infer
-them. In the rare case where the compiler needs assistance, though, the
-arguments and return types may be annotated.
+a single expression. Remember that a block, `{ <expr1>; <expr2>; ... }`, is
+considered a single expression: it evaluates to the result of the last
+expression it contains if that expression is not followed by a semicolon,
+otherwise the block evaluates to `()`.
+
+The types of the arguments are generally omitted, as is the return type,
+because the compiler can almost always infer them. In the rare case where the
+compiler needs assistance, though, the arguments and return types may be
+annotated.
 
 ~~~~
 let square = |x: int| -> uint { x * x as uint };