How to iterate string enum values?

Ogion ogion.art at gmail.com
Fri Dec 27 12:04:35 UTC 2024


On Monday, 23 December 2024 at 20:26:47 UTC, bauss wrote:
> Simply cast el to a string instead of using std.conv.to, that 
> way you retrieve the values.
>
> ```
> auto values = [EnumMembers!BodyType]
>     .map!(el => cast(string)el)
>     .array;
> ```

Or use `std.conv.asOriginalType` to avoid implicit cast:

```D
auto values = [EnumMembers!BodyType]
      .map!asOriginalType
      .array;
  ```



More information about the Digitalmars-d-learn mailing list