On Saturday, 29 June 2019 at 09:28:03 UTC, BoQsc wrote:
However, setting the variable via "environment.opIndexAssign"
seems to not work.
What should we do?
I don't know.
I'm glad I'm on this forum, I know exactly what you did wrong mr.
BoQsc
I checked the documentation and it seems that, you assumed the
wrong syntax for "environment.opIndexAssign()"
The correct syntax is:
environment.opIndexAssign("Some Random Value Here",
"variableName");
And not this one:
environment.opIndexAssign("variableName", "Some Random Value
Here");
Take a look at this documentation once more:
https://dlang.org/library/std/process/environment.op_index_assign.html
import std.stdio : writeln;
import std.array : replace;
import std.process : environment;
void main(){
// Retrieve environment variable "path" for testing if it is
possible
// to retrieve it by using D language Phobos Library
auto environmentPaths = environment.get("path");
writeln(environmentPaths); // Works as expected: we can see the
output of Paths.
// Create a new Environement variable for testing if it is
possible
// to Create it with D language Phobos Library
environment.opIndexAssign("Some Random Value Here",
"variableName");
auto environmentalVariable = environment.get("variableName");
writeln(environmentalVariable); //Unexpected: absolutely no
output.
}