Adding the ?. null verification

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 18 12:56:01 PDT 2014


On Wed, Jun 18, 2014 at 03:46:40PM -0400, Etienne via Digitalmars-d wrote:
> >This also allows you to do a complete null check in a single
> >statement:
> >
> >	if (maybe(tree).left.right.right.left.right !is null) {
> >		// do something with that value
> >	}
> >
> >If nothing else, this at least saves you the trouble of having to
> >check every intermediate reference in the chain. :)
> >
> 
> Very clever, this should go straight to std.typecons. I'm definitely
> ripping it for my project, if you can just scratch something like a
> boost license on it ;)

Feel free to copy it and do whatever you want with it. It's public
domain code, as of right now. :)


T

-- 
Marketing: the art of convincing people to pay for what they didn't need
before which you can't deliver after.


More information about the Digitalmars-d mailing list