immutable array in constructor

Rene Zwanenburg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 17 04:27:01 PDT 2016


On Thursday, 17 March 2016 at 10:11:43 UTC, Jeff Thompson wrote:
> This is a simplified example from a larger class I have where I 
> need an immutable constructor. This is because I need to 
> construct an object an pass it to other functions which take an 
> immutable object. So, how to keep an immutable constructor?

In that case, new immutable C() should work I believe. Also, if 
you mark the constructor as pure, new C() should be implicitly 
convertible to an immutable C.


More information about the Digitalmars-d-learn mailing list