How do I create an enum type?

#1

I’m trying to create an enum type, but I haven’t been able to find any documentation.

I used c3ShowType to look up the Interval enum and view the declaration of the type and the fields, which gave me the following syntaxes:
enum type Interval
SECOND: string constant 'SECOND'

This led me to try to create my own enum type using the following syntax:

enum type Foo {
  BAR: string constant 'Bar'
}

However, I receive the following error:
[Message] Invalid metadata in tag Slooz in tenant project: in "project/enum/Foo.c3typ": project/enum/Foo.c3typ [3,7] E no viable alternative at input 'string'

What’s the correct syntax for creating an enum type?

1 Like

#2

It can look something like this:

enum type Interval {
  SECOND,
  MINUTE,
  TWO_MINUTES = "TWO MINUTES",
  HOUR
}
1 Like