How to initialize immutable variables with an expression that throws an exception to catch?
FeepingCreature
feepingcreature at gmail.com
Fri Apr 3 13:14:27 UTC 2020
On Friday, 3 April 2020 at 12:49:27 UTC, Steven Schveighoffer
wrote:
> Do it the old-fashioned way -- use casting ;)
>
> S s_val = void;
> try
> s_val = fun();
> catch (Exception)
> return;
>
> immutable s = s_val.assumeUnique;
> call(s);
>
Doesn't work - `immutable struct` means S is always immutable.
More information about the Digitalmars-d
mailing list