Variable Arguments
Jethro via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 8 23:30:29 PDT 2017
void foo(A...)(A a)
{
foreach(aa; a)
{
for(int i = 0; i < a.length; i++)
...
}
}
A can be strings or char, how can I easily deal with both? (e.g.,
a.length = 1 for a being a char... and also a[0] = a, so to
speak).
That is, I want chars to be treated as strings of length 1, since
I have written my code to work with strings, no reason it
shouldn't work with chars. I realize we can't use the above
notation but I can't get the type of aa because D complains it is
unknown at compile time. I could use A[k] but it requires extra
work.
More information about the Digitalmars-d-learn
mailing list