getting rid of immutable (or const)

berni someone at somewhere.com
Thu Sep 5 11:28:29 UTC 2019


On Thursday, 5 September 2019 at 11:22:15 UTC, drug wrote:
> 05.09.2019 14:17, berni пишет:
>>> Point[long] q;
>>>
>>> q[1] = Point(3);
>> 
>> Leads to:
>> 
>>> test.d(7): Error: cannot modify struct q[1L] Point with 
>>> immutable members
>> 
>> 
> But why do you try to modify immutable data? What is your 
> point? Could you describe you use case?

That's probably, what I don't understand. I've got a Point, which 
should not be modified. I put it in a container (q) and later I 
get it out there again. It should still be the same Point as 
before. I modify the container, not the Point, don't I?


More information about the Digitalmars-d-learn mailing list