Struct immutable data and dict
    Patric Dexheimer via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Wed Oct  5 20:05:18 PDT 2016
    
    
  
On Thursday, 6 October 2016 at 02:09:44 UTC, Adam D. Ruppe wrote:
> On Thursday, 6 October 2016 at 01:23:35 UTC, Patric Dexheimer 
> wrote:
>> Why?
>
> Because you'd be overwriting that immutable member. Structs 
> just put structure around their contents, but it doesn't change 
> their nature. That struct is no different than if you wrote 
> `immutable size_t` as the value - and of course, overwriting 
> that; changing that violates that promise that you won't change 
> it.
>
> You could store pointers to those structs though, and overwrite 
> the pointer.
But why i´m overwriting the struct if its the first time i´m 
putting it there? (like on the array).
    
    
More information about the Digitalmars-d-learn
mailing list