Built-in sumtypes, case and noreturn: why block enders should be expressions.
rikki cattermole
rikki at cattermole.co.nz
Mon Oct 24 17:45:17 UTC 2022
On 24/10/2022 7:20 PM, FeepingCreature wrote:
>
> ```
> (int | string) foo;
> ...
> int i = foo.case(int i: i, string s: return null);
> ```
That is kinda brilliant.
The first case sets what actually gets returned the others all return
nothing and are inherited from it.
I assume if the other cases get hit that it sets to 0? (unless of course
its boxed)
More information about the Digitalmars-d
mailing list