summary refs log tree commit diff
path: root/doc/tutorial/data.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/tutorial/data.md')
-rw-r--r--doc/tutorial/data.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/tutorial/data.md b/doc/tutorial/data.md
index 678714d388b..7796da21382 100644
--- a/doc/tutorial/data.md
+++ b/doc/tutorial/data.md
@@ -103,6 +103,24 @@ equivalent to a C enum:
 This will define `north`, `east`, `south`, and `west` as constants,
 all of which have type `direction`.
 
+When the enum is is C like, that is none of the variants have
+parameters, it is possible to explicit set the discriminator values to
+an integer value:
+
+    enum color {
+      red = 0xff0000;
+      green = 0x00ff00;
+      blue = 0x0000ff;
+    }
+
+If an explicit discriminator is not specified for a variant, the value
+defaults to the value of the previous variant plus one.  If the first
+variant does not have a discriminator, it defaults to 0.  For example,
+the value of `north` is 0, `east` is 1, etc.
+
+When an enum is C-like the `as` cast operator can be used to get the
+discriminator's value.
+
 <a name="single_variant_enum"></a>
 
 There is a special case for enums with a single variant. These are