difference between x = Nullable.init and x.nullify

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 4 03:32:43 PDT 2017


On Sunday, June 04, 2017 09:31:24 vit via Digitalmars-d-learn wrote:
> On Sunday, 4 June 2017 at 09:04:14 UTC, Jonathan M Davis wrote:
> > [...]
>
> Why Nullable!T call destroy for reference types?

It calls destroy for everything. Why it does that instead of simply
assigning T.init and setting _isNull to true, I don't know. Maybe the commit
history would say, but unless it was done as part of a bugfix, it's more
likely that you'd have to use the commit history to figure out who made it
do that and ask them. Thinking about it though, it does seem like it's
probably the wrong behavior. I'd guess that it was done with structs in
mind, and it doesn't usually make sense to put a class reference in Nullable
outside of generic code, since they can be null on their own.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list