documented void context
This commit is contained in:
parent
051e418129
commit
bc725eaa13
1 changed files with 18 additions and 0 deletions
|
|
@ -60,6 +60,24 @@ An empty ``discard`` statement is often used as a null statement:
|
|||
else: discard
|
||||
|
||||
|
||||
Void context
|
||||
------------
|
||||
|
||||
In a list of statements every expression except the last one needs to have the
|
||||
type ``void``. In addition to this rule an assignment to the builtin ``result``
|
||||
symbol also triggers a ``void`` context:
|
||||
|
||||
.. code-block:: nim
|
||||
proc invalid*(): string =
|
||||
result = "foo"
|
||||
"invalid" # Error: value of type 'string' has to be discarded
|
||||
|
||||
.. code-block:: nim
|
||||
proc valid*(): string =
|
||||
let x = 317
|
||||
"valid"
|
||||
|
||||
|
||||
Var statement
|
||||
-------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue