October 07, 2006 name shadowing in if statement | ||||
|---|---|---|---|---|
| ||||
I think I saw something about this one but I couldn't find the post.
<code>
import std.stdio;
void main()
{
int i = 1;
if(int i = i)// new "i" shadows old "i"
{
i=6;
witef("i=",i,\n);
}
witef("i=",i,\n);
}
</code>
<output>
i=6
i=1
</output>
| ||||
October 12, 2006 Re: name shadowing in if statement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BCS Attachments: | BCS schrieb am 2006-10-07: > I think I saw something about this one but I couldn't find the post. > ><code> > import std.stdio; > > void main() > { > int i = 1; > > if(int i = i)// new "i" shadows old "i" > { > i=6; > witef("i=",i,\n); > } > witef("i=",i,\n); > } ></code> > ><output> > i=6 > i=1 ></output> Added to DStress as http://dstress.kuehne.cn/nocompile/i/if_15_A.d Thomas | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply