Re: Setting default values for Main function's args Array

2019-06-27 Thread Vaidas via Digitalmars-d-learn
On Thursday, 27 June 2019 at 17:22:36 UTC, Paul Backus wrote: On Thursday, 27 June 2019 at 17:20:37 UTC, Paul Backus wrote: void main(string[] args) { string[] defaultArgs = ["my", "default", "arguments"]; if (args.length == 0) { args = defaultArgs; } // Process args... }

Re: Setting default values for Main function's args Array

2019-06-27 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 27 June 2019 at 17:05:05 UTC, Vaidas wrote: Is it possible to set the default values for the Main function's arguments? It seems that I'm getting Range error. import std.stdio : writeln; void main(string[] args = ["asdsfasdf", "asdklfajsdk", "asdfasdfasd"]){ writeln("", args

Re: Setting default values for Main function's args Array

2019-06-27 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 27 June 2019 at 17:20:37 UTC, Paul Backus wrote: void main(string[] args) { string[] defaultArgs = ["my", "default", "arguments"]; if (args.length == 0) { args = defaultArgs; } // Process args... } Correction: you should check for `args.length == 1`, since (

Re: Setting default values for Main function's args Array

2019-06-27 Thread wjoe via Digitalmars-d-learn
On Thursday, 27 June 2019 at 17:05:05 UTC, Vaidas wrote: Is it possible to set the default values for the Main function's arguments? It seems that I'm getting Range error. import std.stdio : writeln; void main(string[] args = ["asdsfasdf", "asdklfajsdk", "asdfasdfasd"]){ writeln("", args

Re: Setting default values for Main function's args Array

2019-06-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 June 2019 at 17:05:05 UTC, Vaidas wrote: Is it possible to set the default values for the Main function's arguments? No, as far as the language is concerned, a value is always being passed from the operating system, so those default values would never trigger. What you could