newbie question: Can D do this?
Steven Schveighoffer
schveiguy at yahoo.com
Tue Dec 20 07:25:27 PST 2011
On Tue, 20 Dec 2011 09:18:16 -0500, clk <clk at clksoft.com> wrote:
> Thank you for your quick replies. I'm impressed by the helpfulness and
> dedication of the D community!
> Here's another one. Is there a way to pass arguments to functions by
> keyword as in the calls to f and g below?
>
> void f(int a = 0, int b = 1) {}
> void g(int a) {}
>
> void main() {
> f(b = 1, a = 0); // compile error
> g(a = 0); // also compile error
> }
No. There are workarounds, but they are quite ugly.
-Steve
More information about the Digitalmars-d-learn
mailing list