digitalmars.D.learn - Call method of object variable
- Andrey (3/19) Oct 16 2020 How to call alias "method" on object "qaz"?
- Simen =?UTF-8?B?S2rDpnLDpXM=?= (6/25) Oct 16 2020 https://dlang.org/spec/traits.html#child
- Andrey (1/1) Oct 16 2020 Thank you!
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"?
Oct 16 2020
On Friday, 16 October 2020 at 08:12:59 UTC, Andrey wrote:Hi, I have got:https://dlang.org/spec/traits.html#child The resulting code would be: __traits(child, qaz, method)(/*arguments go here*/); -- Simenstruct 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"?
Oct 16 2020