digitalmars.D - Static Variable Scoping in D
- Leo Custodio (13/13) Mar 23 2021 int x = 10;
- Adam D. Ruppe (4/5) Mar 23 2021 D uses the inner-most name available when it can. You can ask it
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
Mar 23 2021
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
Mar 23 2021