Re: Private nested class instance accessed via outer class public interface

2023-06-16 Thread Anonymouse via Digitalmars-d-learn
On Friday, 16 June 2023 at 07:47:50 UTC, Murloc wrote: 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 toS

Re: Private nested class instance accessed via outer class public interface

2023-06-16 Thread Murloc via Digitalmars-d-learn
On Friday, 16 June 2023 at 07:54:21 UTC, Richard (Rikki) Andrew Cattermole wrote: Also we have a Discord server which you are welcome to join! https://discord.gg/bMZk9Q4 Thanks for the invitation. However, I don't like Discord so I don't use it :)

Re: Private nested class instance accessed via outer class public interface

2023-06-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Yes that is to be expected. Also we have a Discord server which you are welcome to join! https://discord.gg/bMZk9Q4

Re: Private nested class instance accessed via outer class public interface

2023-06-16 Thread Murloc via Digitalmars-d-learn
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(O

Private nested class instance accessed via outer class public interface

2023-06-16 Thread Murloc via Digitalmars-d-learn
I'm not sure if this behavior is desired and have any use-cases (should I report it as a bug?), but, for example, C# doesn't allow this. ```d import std.conv; class Outer { private static class Inner { private int field = 30; override string toString() => to!string(field);

Private nested class instance accessed via outer class public interface

2023-06-16 Thread Murloc via Digitalmars-d-learn
I'm not sure if this behavior is desired and have any use-cases (should I report it as a bug?), but, for example, C# doesn't allow this. ```d import std.conv; class Outer { private static class Inner { private int field = 30; override string toString() => to!string(field);