On 2017-10-27 01:04, bauss wrote:

The first example would not equal the second, because you could set bar from anywhere within the module.

Immutable will already do your behavior.

class Foo
{
     immutable string bar;

     this(string baz)
     {
         bar = baz;
     }
}

That only works for primitive types. For anything else (like a class or struct) you won't be able to modify the internal state. While with the with the initial example you can.

--
/Jacob Carlborg

Reply via email to