Re: How do I make only the array itself immutable?

2018-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 15, 2018 02:06:23 Marc via Digitalmars-d-learn wrote: > Can I make it work? > > >struct S > >{ > > > > int[] l; > > > >} > > then > > >auto s = S(); > >s.l ~= 1; // ok > >s.l = []; // error It's not possible to do anything like that, and it really doesn't make sense when you con

How do I make only the array itself immutable?

2018-03-14 Thread Marc via Digitalmars-d-learn
Can I make it work? struct S { int[] l; } then auto s = S(); s.l ~= 1; // ok s.l = []; // error