How to use sets in D?
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Feb 8 21:58:49 UTC 2022
On Tue, Feb 08, 2022 at 09:47:13PM +0000, Paul Backus via Digitalmars-d-learn wrote:
[...]
> The `alias` and the `enum` just make the code a little nicer to read
> by letting you write `Unit` instead of `void[0]` and `unit` instead of
> `void[0].init`. You could get rid of them and the code would work
> exactly the same way; it'd just be a little bit uglier:
>
> void[0][E] mySet;
>
> mySet[...] = void[0].init;
[...]
Unfortunately, this doesn't work due to a syntax restriction (the parser
isn't expecting a type name after the `=`, and will raise a syntax
error). So the alias is in fact necessary.
T
--
Fact is stranger than fiction.
More information about the Digitalmars-d-learn
mailing list