If Statement with Declaration

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 19 11:29:57 PDT 2017


On Wed, Jul 19, 2017 at 01:30:56PM +0000, sontung via Digitalmars-d wrote:
[...]
>     if(int i = someFunc(); i >= 0)
>     {
>         // use i
>     }
> Thoughts on this sort of feature?

I've been wanting such a feature for a long time now. Though I'd propose
a different syntax:

	if ((int i = someFunc()) >= 0)
	{
		...
	}


T

-- 
I've been around long enough to have seen an endless parade of magic new techniques du jour, most of which purport to remove the necessity of thought about your programming problem.  In the end they wind up contributing one or two pieces to the collective wisdom, and fade away in the rearview mirror. -- Walter Bright


More information about the Digitalmars-d mailing list