Proper Use of Assert and Enforce

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 5 00:01:20 PST 2016


> It is purely a way to make throwing an exception use a syntax 
> similar to assert and save a line of code.
>
> if(!condition)
>     throw new Exception(msg);
>
> becomes
>
> enforce(condition, msg);


So enforce is just macros on top of:
if(!condition)
     throw new Exception(msg);

?


More information about the Digitalmars-d-learn mailing list