On Saturday, 2 January 2021 at 21:41:34 UTC, Paul wrote:
On Saturday, 2 January 2021 at 03:20:29 UTC, Paul Backus wrote:
D's switch statement only works on strings and integers. For more complex values, the easiest thing is to just use an if-else chain.

If you really want to use a switch statement, you can do it by defining a function that maps each of your enum values to a unique integer; for example:

Im afraid that would still result in issues when duplicate enum vlues are at play right?

Yes, but this will be true of any approach you choose. If two enum members have exactly the same value, there is no way to distinguish between them, either at compile time or at runtime.

Reply via email to