Key arguments

baleog maccarka at yahoo.com
Sun Jul 13 23:17:17 PDT 2008


How can i implement key arguments in D? I want something like this:
--
void f(int x, double y = 2.0, int z = 3);
...
f(1, z:10, y:5.1); // x=1, y=5.1, z=10
f(1, z:10); // x=1, y=2.0, z=10
--
I tried to do this with Variant type and explicit type checking. But it takes a lot of routine actions. Maybe exists a better way?

Best regards


More information about the Digitalmars-d-learn mailing list