DIPX: Enum Literals / Implicit Selector Expression
Nick Treleaven
nick at geany.org
Sat Jul 2 11:31:15 UTC 2022
On Friday, 1 July 2022 at 10:49:46 UTC, user1234 wrote:
> On Friday, 1 July 2022 at 09:02:12 UTC, Ola Fosheim Grøstad
> wrote:
>> C and D don't have an enumeration type. `enum class` gave C++
>> a somewhat type safe enumeration type. It is very useful.
>
> Absolutely. This is why we can write this insanity:
>
> ```d
> enum E {absolutely}
> const a =
> E.absolutely.absolutely.absolutely.absolutely.absolutely;
> ```
Isn't that just because a value also has the properties of its
type? So even if D was strict about only using declared values
for an enum type instance, your example would still work.
More information about the Digitalmars-d
mailing list