diff options
Diffstat (limited to 'doc/manual/stmts.txt')
-rw-r--r-- | doc/manual/stmts.txt | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/doc/manual/stmts.txt b/doc/manual/stmts.txt index 59f7eef55..83852b1ff 100644 --- a/doc/manual/stmts.txt +++ b/doc/manual/stmts.txt @@ -234,11 +234,11 @@ Example: var name = readLine(stdin) if name == "Andreas": - echo("What a nice name!") + echo "What a nice name!" elif name == "": - echo("Don't you have a name?") + echo "Don't you have a name?" else: - echo("Boring name...") + echo "Boring name..." The ``if`` statement is a simple way to make a branch in the control flow: The expression after the keyword ``if`` is evaluated, if it is true @@ -269,17 +269,17 @@ Example: case readline(stdin) of "delete-everything", "restart-computer": - echo("permission denied") - of "go-for-a-walk": echo("please yourself") - else: echo("unknown command") + echo "permission denied" + of "go-for-a-walk": echo "please yourself" + else: echo "unknown command" # indentation of the branches is also allowed; and so is an optional colon # after the selecting expression: case readline(stdin): of "delete-everything", "restart-computer": - echo("permission denied") - of "go-for-a-walk": echo("please yourself") - else: echo("unknown command") + echo "permission denied" + of "go-for-a-walk": echo "please yourself" + else: echo "unknown command" The ``case`` statement is similar to the if statement, but it represents @@ -326,13 +326,13 @@ Example: .. code-block:: nim when sizeof(int) == 2: - echo("running on a 16 bit system!") + echo "running on a 16 bit system!" elif sizeof(int) == 4: - echo("running on a 32 bit system!") + echo "running on a 32 bit system!" elif sizeof(int) == 8: - echo("running on a 64 bit system!") + echo "running on a 64 bit system!" else: - echo("cannot happen!") + echo "cannot happen!" The ``when`` statement is almost identical to the ``if`` statement with some exceptions: @@ -435,7 +435,7 @@ Example: if a[j][i] == 7: found = true break myblock # leave the block, in this case both for-loops - echo(found) + echo found The block statement is a means to group statements to a (named) ``block``. Inside the block, the ``break`` statement is allowed to leave the block @@ -462,10 +462,10 @@ While statement Example: .. code-block:: nim - echo("Please tell me your password: \n") + echo "Please tell me your password: \n" var pw = readLine(stdin) while pw != "12345": - echo("Wrong password! Next try: \n") + echo "Wrong password! Next try: \n" pw = readLine(stdin) |