From 25955440df3bf32b058ed27bdc2e619874f0d4ee Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 27 Oct 2020 07:27:02 +0100 Subject: [PATCH] Document implicit return values from procedures (#15738) --- doc/tut1.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/tut1.rst b/doc/tut1.rst index 24874096c7..68e74df522 100644 --- a/doc/tut1.rst +++ b/doc/tut1.rst @@ -641,6 +641,16 @@ initialised with the type's default value. Note that referential data types will be ``nil`` at the start of the procedure, and thus may require manual initialisation. +A procedure that does not have any ``return`` statement and does not use the +special ``result`` variable returns the value of its last expression. For example, +this procedure + +.. code-block:: nim + :test: "nim c $1" + proc helloWorld(): string = + "Hello, World!" + +returns the string "Hello, World!". Parameters ----------