Promote "echo" syntax without parenthesis

This commit is contained in:
Adam Stankiewicz 2016-01-26 09:40:44 +01:00
commit cd574d1976
7 changed files with 93 additions and 93 deletions

View file

@ -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)