Static method of inner class needs this

rumbu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 8 23:32:32 PST 2015


class Outer
{
     class Inner
     {
         static Inner createInner()
         {
             return new Inner(); //need 'this' to access member 
this
         }
     }
}

Is this a bug?

If Inner is not nested, it works as expected:

class Inner
{
     static Inner createInner()
     {
         return new Inner()
     }
}

D version: 2.066.1


More information about the Digitalmars-d-learn mailing list