Private variables accessible from outside class

Paul Backus snarwin at gmail.com
Thu Aug 8 15:57:45 UTC 2019


On Thursday, 8 August 2019 at 15:51:45 UTC, Drobet wrote:
> I'm having a weird issue, where after defining my classes 
> variables as private, they can still be modified and looked at 
> from the outside. That leads to this code compiling with no 
> issues.
>
> [...]
>
> My question is if this is intended behavior, and if yes, why?

For some context on why private works the way it does in D, take 
a look at this post on the official D blog:

https://dlang.org/blog/2018/11/06/lost-in-translation-encapsulation/


More information about the Digitalmars-d-learn mailing list