alias to struct method
Marc
jckj33 at gmail.com
Fri Dec 22 17:53:34 UTC 2017
How can I create a alias to a struct method?
> struct S {
> string doSomething(int n) { return ""; }
> }
I'd like to do something like this (imaginary code):
alias doSomething = S.doSomething;
then call it by doSomething(3)
I got the following error from this code:
> Error: need 'this' for 'gen' of type 'string(int n)'
So I tried create a instance:
> alias doSomething = S().doSomething;
Changes the error to:
> app.d(96): Error: function declaration without return type.
> (Note that > constructors are always named this)
> app.d(96): Error: semicolon expected to close alias declaration
More information about the Digitalmars-d-learn
mailing list