Link Search Menu Expand Document

Enums

Table of contents

  1. Enums

Enums

Enums are a collection of constants which can be accessed via a name rather than an index to document intent. Unlike other languages, enums in Dictu must be assigned to a value when declaring the enum and no automatic value will be generated.

enum Test {
    a = 0,
    b = 1,
    c = 2
}

print(Test.a); // 0

Enums in Dictu also do not care about the value being stored within the enum, so if you wanted to create a heterogeneous enum, Dictu will not stop you.

enum HeterogeneousEnum {
    a = 0,
    b = "string",
    c = def () => 10
}

This site uses Just The Docs, with modifications.