Can someone explain why i can change this immutable variable please?
Daniel Davidson
nospam at spam.com
Wed Oct 9 09:09:16 PDT 2013
On Wednesday, 9 October 2013 at 15:33:23 UTC, Ali Çehreli wrote:
>
> That string is independent from the argument (i.e. Bar.name).
> They initially share the same characters. Either of those
> strings can leave this sharing at will, and that is exactly
> what name="tess" does. 'name' now refers to different
> immutable chars.
>
And to prove it - change main to:
void main(string[] args)
{
auto bar = new Bar();
bar.test();
writeln(Bar.name);
}
and as much as you may want to become tess, you will still be
gary.
More information about the Digitalmars-d-learn
mailing list