Nullable!T with T of class type
kdevel
kdevel at vogtner.de
Tue Jun 26 19:03:20 UTC 2018
On Monday, 25 June 2018 at 22:58:41 UTC, Jonathan M Davis wrote:
> On Monday, June 25, 2018 19:40:30 kdevel via
> Digitalmars-d-learn wrote:
>> R r;
>>
>> if (r.s is null)
>> throw new Exception ("some error message");
[...]
>> Why can't this programming error be detected at compile time?
>
> If you have a function that accepts Nullable!T, when that
> function is called, how on earth is it going to know whether
> the argument it received was null at compile time?
That was not the error. The error was that I used is null instead
of .isNull() which lead to a different Exception (Error).
[...]
> If you really don't want the extra bool, then just don't use
> Nullable. Class references are already naturally nullable.
Sure.
More information about the Digitalmars-d-learn
mailing list