string <-> null/bool implicit conversion

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 20 11:05:51 PDT 2015


On Thu, Aug 20, 2015 at 01:50:11PM -0400, Steven Schveighoffer via Digitalmars-d wrote:
[...]
> The main reason why it caused issues is this nice idiom:
> 
> if(auto arr = someFunction())
> {
>    // use arr
> }
> 
> This would HAVE to be split out to two statements, and the arr variable
> would be scoped outside of the if statement.
[...]

I wish the language would accept:

	if ((auto arr = someFunction()) !is null)
	{
		...
	}

But IIRC, auto cannot be used except at the top level expression.


T

-- 
Windows 95 was a joke, and Windows 98 was the punchline.


More information about the Digitalmars-d mailing list