From 2ee6d209c29bf2abe991a11468221c24d21ebbfc Mon Sep 17 00:00:00 2001 From: Tomohiro Date: Fri, 5 Jul 2019 08:43:14 +0900 Subject: [PATCH] manual: document block expression (#11638) (cherry picked from commit b64dd795b136248a60b8476d16bfe6e964b7fe18) --- doc/manual.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/manual.rst b/doc/manual.rst index 97a5b80530..31ca1e7735 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -3088,6 +3088,21 @@ As seen in the above example, the case expression can also introduce side effects. When multiple statements are given for a branch, Nim will use the last expression as the result value. +Block expression +---------------- + +A `block expression` is almost like a block statement, but it is an expression +that uses last expression under the block as the value. +It is similar to the statement list expression, but the statement list expression +does not open new block scope. + +.. code-block:: nim + let a = block: + var fib = @[0, 1] + for i in 0..10: + fib.add fib[^1] + fib[^2] + fib + Table constructor -----------------