Call method of object variable

Andrey saasecondbox at yandex.ru
Fri Oct 16 08:12:59 UTC 2020


Hi,
I have got:
> struct Qaz
> {
>     wstring read() {return null;}
>     wstring hear() {return "rrrr";} }
> 
> void main()
> {
>     // ...
>     static if(some_condition) alias method = Qaz.hear;
>     else alias method = Qaz.read;
> 
>     // ...
>     Qaz qaz;
> 
>     qaz.method(); // ???
> }

How to call alias "method" on object "qaz"?


More information about the Digitalmars-d-learn mailing list