And since classes can be declared locally inside methods, you can also do something similar this way:

```d
import std.stdio;
import std.conv;

Object getB() {
    class B {
                private int field = 30;
        override string toString() => to!string(field);
        }
    return cast(Object)new B();
}

void main() {
    auto b = getB();
    writeln(b); // 30
}
```
  • Private nested c... Murloc via Digitalmars-d-learn
    • Private nes... Murloc via Digitalmars-d-learn
      • Re: Pri... Murloc via Digitalmars-d-learn
        • Re:... Anonymouse via Digitalmars-d-learn
      • Re: Pri... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
        • Re:... Murloc via Digitalmars-d-learn

Reply via email to