View source code
Display the source code in std/process.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.process.environment.opBinaryRight
Identify whether a variable is defined in the environment.
bool opBinaryRight(string op : "in")
(
scope const(char)[] name
) @trusted;
Because it doesn't return the value, this function is cheaper than get
.
However, if you do need the value as well, you should just check the
return of get
for null
instead of using this function first.
Example
// good usage
if ("MY_ENV_FLAG" in environment)
doSomething();
// bad usage
if ("MY_ENV_VAR" in environment)
doSomething(environment["MY_ENV_VAR"]);
// do this instead
if (auto var = environment .get("MY_ENV_VAR"))
doSomething(var);
Authors
Lars Tandle Kyllingstad, Steven Schveighoffer, Vladimir Panteleev
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.