Tutorial 1: Simplifiy the discription of enums; it is a tutorial, not a manual
This commit is contained in:
parent
36473acf47
commit
6fd0a33265
1 changed files with 2 additions and 11 deletions
13
doc/tut1.rst
13
doc/tut1.rst
|
|
@ -1112,21 +1112,12 @@ proc can convert it to its underlying integer value.
|
||||||
|
|
||||||
For better interfacing to other programming languages, the symbols of enum
|
For better interfacing to other programming languages, the symbols of enum
|
||||||
types can be assigned an explicit ordinal value. However, the ordinal values
|
types can be assigned an explicit ordinal value. However, the ordinal values
|
||||||
must be in ascending order. A symbol whose ordinal value is not
|
must be in ascending order.
|
||||||
explicitly given is assigned the value of the previous symbol + 1.
|
|
||||||
|
|
||||||
An explicit ordered enum can have *holes*:
|
|
||||||
|
|
||||||
.. code-block:: nim
|
|
||||||
:test: "nim c $1"
|
|
||||||
type
|
|
||||||
MyEnum = enum
|
|
||||||
a = 2, b = 4, c = 89
|
|
||||||
|
|
||||||
|
|
||||||
Ordinal types
|
Ordinal types
|
||||||
-------------
|
-------------
|
||||||
Enumerations without holes, integer types, ``char`` and ``bool`` (and
|
Enumerations, integer types, ``char`` and ``bool`` (and
|
||||||
subranges) are called ordinal types. Ordinal types have quite
|
subranges) are called ordinal types. Ordinal types have quite
|
||||||
a few special operations:
|
a few special operations:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue