getting rid of immutable (or const)

berni someone at
Fri Sep 6 09:09:22 UTC 2019

On Thursday, 5 September 2019 at 20:10:03 UTC, ag0aep6g wrote:
> You're not putting an immutable int into an AA. You're copying 
> the value of an immutable int to a mutable one.
>> but I can't do that with a struct, having an immutable member. 
>> When I remove that immutable inside of the struct it works. ?!?
> `Point` is effectively the same as `immutable long`. A better 
> simile would be this: `immutable(int)[int] a; a[1] = 17;`. And 
> now you get the same error. You can't overwrite the element, 
> because its immutable.

Ah, the point is not, that my object contains an immutable 
element, but that the base type of the AA is a type with an 
immutable element! I understand now. Thanks a lot!

More information about the Digitalmars-d-learn mailing list