Can Enums be integral types?

Bastiaan Veelo Bastiaan at Veelo.net
Tue Apr 19 13:20:21 UTC 2022


On Tuesday, 19 April 2022 at 01:25:13 UTC, Era Scarecrow wrote:
> The 'integral' or numeric value is used for uniqueness, […]

There is nothing that requires enum values to be unique, though:
```d
import std;
void main()
{
     enum E {Zero = 0, One = 0, Two = 0}
     writeln(E.Two); // Zero!
}
```

— Bastiaan.


More information about the Digitalmars-d-learn mailing list