Non-null objects, the Null Object pattern, and T.init
Timon Gehr
timon.gehr at gmx.ch
Mon Jan 20 12:42:36 PST 2014
On 01/20/2014 01:44 AM, Michel Fortin wrote:
>
> That's one way to do it. Note that this means you can't assign null to
> 'a' inside the 'if' branch. ...
Such an assignment could downgrade the type again. An alternative would
be to not use flow analysis at all and require eg:
A? a=foo();
if(A b=a){
// use b of type 'A' here
}
A solution that sometimes allows A? to be dereferenced will likely have
issues with eg. IFTI.
More information about the Digitalmars-d
mailing list