We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Tips for golfing in D2
// use i.writeln; // instead of writeln(i); // use writeln; // instead of writeln();
Use the ternary operator (?:) or &&/||:
?:
&&
||
if(i>0)i.write; if(i)i.write; i?i.write:0; i&&i.write;
auto
string s="foo"; auto s="foo";
If your program terminates by error, you can replace void main with int main. For example, the shortest way to loop over args:
void main
int main
import std;int main(string[]a){for(int i;;)a[++i].writeln;}
The compiler may have told you,
function D main parameter list must be empty or accept one parameter of type string[]
D main
string[]
but actually, the main function can accept a char[][] parameter instead. This can allow you to use split on an argument instead of splitter.
char[][]
split
splitter