On 09/18/2014 12:52 PM, bearophile wrote:

> Can someone show one or more usage cases?

I can't claim that I have experience with multiple alias this ;) but I like the following example that I had come up with:

class TeachingAssistant
    Student studentIdentity;
    Teacher teacherIdentity;

    this(string name, string subject)
        this.studentIdentity = new Student(name);
        this.teacherIdentity = new Teacher(name, subject);

    /* The following two 'alias this' declarations will enable
     * this type to be used both as a Student and as a Teacher. */
    alias teacherIdentity this;
    alias studentIdentity this;


[1] http://ddili.org/ders/d.en/alias_this.html

Reply via email to