about the new const regime

Daniel919 Daniel919 at web.de
Wed Jan 2 04:10:17 PST 2008


> The difference is :
> 
> string s = "bla";
> s = "abc";     // compile, you can reassign to an invariant array with 
> another invariant array, but you can't change it partially.
> s[0] = 'x'; //error as you said

But the same is true for a const(char)[].
const(char)[] s = "bla";
s = "abc";
s[0] = 'x'; //error

const char[] s = "bla";
s = "abc" //error

invariant char[] s = "bla";
s = "abc" //error



More information about the Digitalmars-d mailing list