Empty Associative Aarray Literal
Jack Stouffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 3 14:06:54 PST 2016
I want to have one of the parameters on a function be optional.
The problem is, is that it's a AA and D does not seem to support
empty AA literals. Observe:
string func(int a, int[int] b = []) {
return "mem1";
}
void main() {
func(1);
}
$ dmd test
test.d(8): Error: cannot implicitly convert expression ([]) of
type void[] to int[int]
This doesn't work either
string func(int a, int[int] b = int[int].init) {
return "mem1";
}
void main() {
func(1);
}
More information about the Digitalmars-d-learn
mailing list