Skip to content

Enum

An enum is a closed set of named variants.

1
2
3
4
5
enum Deliver {
    To
    Reply
    Forward
}

Use it as a field type, optionally with a default:

1
2
3
struct Message {
    deliver: Deliver = default   // first variant, `To`
}

Variants are bare identifiers. Attaching data to a variant (Encrypt(EncryptionAlgorithm)) is a proposal, not yet part of the language.