On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote:
Is it possible to have a class which has a variable which can be seen from the outside, but which can only be modified from the inside?Something like: class C { int my_var = 3; // semi_const?? void do_something() { my_var = 4; } }
Yes, I prefer this idiom: class C { union { private int var_rw; public const(int) var_ro; } }