documented optional indentation for 'case' statements/'case' objects
This commit is contained in:
parent
09499b3822
commit
48847b5616
5 changed files with 35 additions and 4 deletions
|
|
@ -932,7 +932,10 @@ An example:
|
|||
As can been seen from the example, an advantage to an object hierarchy is that
|
||||
no casting between different object types is needed. Yet, access to invalid
|
||||
object fields raises an exception.
|
||||
|
||||
|
||||
The syntax of ``case`` in an object declaration follows closely the syntax of
|
||||
the ``case`` statement: The branches in a ``case`` section may be indented too.
|
||||
|
||||
|
||||
Set type
|
||||
~~~~~~~~
|
||||
|
|
@ -1732,7 +1735,16 @@ Example:
|
|||
of "delete-everything", "restart-computer":
|
||||
echo("permission denied")
|
||||
of "go-for-a-walk": echo("please yourself")
|
||||
else: echo("unknown command")
|
||||
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")
|
||||
|
||||
|
||||
The `case`:idx: statement is similar to the if statement, but it represents
|
||||
a multi-branch selection. The expression after the keyword ``case`` is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue