immutable array in constructor
Jeff Thompson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 17 09:32:30 PDT 2016
On Thursday, 17 March 2016 at 11:27:01 UTC, Rene Zwanenburg wrote:
> 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.
new immutable C() worked! Thanks for the insight.
More information about the Digitalmars-d-learn
mailing list