Setting up a final switch from a list

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Mar 29 00:37:21 UTC 2024


On Thursday, March 28, 2024 4:21:03 PM MDT Salih Dincer via Digitalmars-d-
learn wrote:
> How can we add all members of an enum type to a list without
> duplicating code?

As the documentation for EnumMembers explains, you can use
std.meta.NoDuplicates to strip out duplicates if you want to do something
like generate a switch statement from the list of enum members.

https://dlang.org/phobos/std_traits.html#EnumMembers

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list