Write variable from other function

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Fri Feb 28 07:15:59 PST 2014


On Friday, 28 February 2014 at 14:15:17 UTC, Suliman wrote:
> I continue attempted to become a programmer, but I have small 
> problem. I can't understand how to write/change variable from 
> one function by code in another.
> http://www.everfall.com/paste/id.php?nqq61th5loq3
>
> writeln(configpath);  // I need write this one! <-- this string
>
> I remember (if I now mistake) that there is way to get access 
> to vars from other class in way like MyClass2.var = 2 but 
> probably I am wrong

You can not access/read/write a variable of another function.


     import std.path : buildPath;
     auto configpath = buildPath(getcwd(), "config.txt");
     if (!isConfigExist(configpath))
     {
         writeln("config do not exists");
         writeln(configpath);  // I need write this one!


More information about the Digitalmars-d-learn mailing list