Wiki: D
GitHub: edit | view

Tips for golfing in D2

Function calls

// use
i.writeln;
// instead of
writeln(i);


// use
writeln;
// instead of
writeln();

Conditions

Use the ternary operator (?:) or &&/||:

if(i>0)i.write;
if(i)i.write;
i?i.write:0;
i&&i.write;

auto keyword

string s="foo";
auto s="foo";