Make a function available under different names.
ryuukk_
ryuukk.dev at gmail.com
Sat Jul 29 16:18:08 UTC 2023
There are 2 ways you can solve your problem
```d
string returnExecutableName(string[] arguments) {
// if you compile with `-debug` it'll run this block
debug {
write("Debug mode is enabled.\n");
write(" Executable_Name: " ~ arguments[0] ~ "\n");
}
return arguments[0];
}
```
```d
string returnExecutableName(string[] arguments) {
// if you compile with `-version=VERBOSE` it'll run this block
version (VERBOSE) {
write("Debug mode is enabled.\n");
write(" Executable_Name: " ~ arguments[0] ~ "\n");
}
return arguments[0];
}
```
You don't even need that function at this point
```d
import std.stdio;
void main(string[] args) {
debug {
write("Debug mode is enabled.\n");
write(" Executable_Name: " ~ args[0] ~ "\n");
}
}
```
There, it's cleaner without indirections
More information about the Digitalmars-d-learn
mailing list