Setting up a final switch from a list

Salih Dincer salihdb at hotmail.com
Fri Mar 29 14:07:09 UTC 2024


On Friday, 29 March 2024 at 00:37:21 UTC, Jonathan M Davis wrote:
> 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

I guess this falls into metaprogramming. Maybe we should expect 
this possibility from IDEs because I've seen something like this 
in VScode. All enum members were added automatically.

SDB at 79


More information about the Digitalmars-d-learn mailing list