Enum values

Hello everyone,

Is it possible to define my enum’s values?
For example in order to start my enum not with 0 (but maybe 100 or whatever), or in order to skip values (like maybe having some options with values -1, 0, 5, 6 and 7, but without options equivalent to 1, 2, 3, 4)

Checkout Enums - Crystal. It has some examples of how the default values can be overridden, as well as changing the “type” of the enum.

1 Like

Oh, thanks!

This should probably be added to the API as well (it says it can be overwritten, but without any more details or examples).

changing the “type”
You even answered my next question already! Thanks!

PRs are welcome :slight_smile:.

Tho this does bring up the question of how to handle things like this that exist in both API and reference material. E.g. what should be included in each place, what should be in both, should one be favored over the other, etc.

1 Like