If Statement with Declaration
Matthias Bentrup via Digitalmars-d
digitalmars-d at puremagic.com
Fri Nov 4 07:16:44 PDT 2016
On Thursday, 3 November 2016 at 22:29:34 UTC, Jerry wrote:
> if(int i = someFunc(); i >= 0)
> {
> // use i
> }
> Thoughts on this sort of feature?
I would prefer the syntax
if( (int i = someFunc()) >= 0 )
{
// use i
}
as this matches the already existing assignment expression syntax
if you pull the declaration out of the if expression.
More information about the Digitalmars-d
mailing list