March 24, 2021 Static Variable Scoping in D | ||||
---|---|---|---|---|
| ||||
int x = 10; int y = 20; void main() { import std.stdio : writeln; int x = 5; { int z; z = y / x; writeln("Value of z is ", z); } } // Output: Value of z is 4 |
March 24, 2021 Re: Static Variable Scoping in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leo Custodio | On Wednesday, 24 March 2021 at 02:06:42 UTC, Leo Custodio wrote:
> [snip]
D uses the inner-most name available when it can. You can ask it to look back at top level with a prefixed .:
z = y / .x; // use x from the top level
|
Copyright © 1999-2021 by the D Language Foundation