How to check if something can be null

Antonio antonio at abrevia.net
Fri Jul 1 17:02:24 UTC 2022


On Friday, 1 July 2022 at 15:35:00 UTC, Adam D Ruppe wrote:
> On Friday, 1 July 2022 at 13:48:25 UTC, Antonio wrote:
>> I has been using this pattern each time something needs 
>> special treatment when it can be null:
>
> i'd prolly check `static if(is(typeof(null) : T))` which means 
> if the null literal implicitly converts to type T.

Perfect!!!  Thanks Adam.

> there's also the bludgeon __traits(compiles, v is null) too lol


love it X-) !!!  may be this is the Swiss knife I was waiting 
for...



More information about the Digitalmars-d-learn mailing list