Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]
zabruk70 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jan 10 02:10:46 PST 2016
Hello.
1st Novice question:
i want function, operates sometimes with char[], sometimes with
ubyte[].
internally it works with ubyte.
i can use overloading:
void myFunc(ubyte[] arg) {...};
void myFunc(char[] arg) { ubyte[] arg2 = cast(ubyte[]) arg; ...}
It is OK. But i want 2 params (arg1, arg2),
so i need write 4 overloading functions.
I fill templated needed, can anybody show me the way?
And 2nd question:
what if additionally to written above, function shuld return
ubyte[] or char[] ?
can compiler guess what return type need from code?
something like:
char[] cc = myFunc()
ubyte[] bb = myFunc()
Thanks.
More information about the Digitalmars-d-learn
mailing list