Static Variable Scoping in D

Leo Custodio custodio.leonardo at gmail.com
Wed Mar 24 02:06:42 UTC 2021


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


More information about the Digitalmars-d mailing list