[Dlang] Delegate Syntax Question

Gary Willoughby via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 10 12:23:23 PST 2016


On Sunday, 10 January 2016 at 14:32:02 UTC, Jack wrote:
> ...

Just to make your code a little more clear, try using aliases 
when defining delegate parameters. Like this:

alias Action = void delegate();

Then in your code you use the alias, like this:

class Bar()
{
     private Action _action;

     void setAction(Action d)
     {
         this._action = d;
     }
}

IMHO it makes everything more readable and you only have one 
definition of the delegate signature.


More information about the Digitalmars-d-learn mailing list