Is there a simple way to check if value is null for every case?

SG s at g.com
Mon Aug 27 14:11:32 UTC 2018


On Monday, 27 August 2018 at 13:02:28 UTC, rikki cattermole wrote:
> So Nullable in D and C# is basically the same except C#'s has 
> language support.

The big difference is that in there I could do:

    int? i = null;
    string j = null;
    var k = null;

and test all like:

     i == null;
     j == null;
     k == null;

but in D:

     Nullable!int i;
     auto j = null;
     string k = null;

     writefln("%s", i.isNull); // I need to invoke Nullable 
property isNull;
     writefln("%s", i == null); // I can't just do this.

     writefln("%s", j == null);
     writefln("%s", k == null);


More information about the Digitalmars-d-learn mailing list