Anything in D to avoid check for null everywhere?

Jack jckj33 at gmail.com
Wed Jan 13 03:13:32 UTC 2021


Currently I'm with this:

auto ref ifNotNull(T, T2)(T lhs, lazy T2 rhs)
{
     if(lhs) {
         rhs();
     }
     return lhs;
}


far from good. I wish there was a way to create a new operator so 
I would make .? similar to C#'s but would evaluate the 
left-handed side only if it's null and do nothing otherwise (C#'s 
evaluate to null, probably due to lack of control of flow 
structure, which isn't possible within a source code, only from 
compiler's side, as far i know)


More information about the Digitalmars-d-learn mailing list