Another prayer for invariant strngs
Christian Kamm
kamm.incasoftware at shift-at-left-and-remove-this.de
Fri Jul 13 13:27:35 PDT 2007
> So does this mean I don't need to be
> making defensive copies of every string?
Yep, dynamic arrays behave very much like pointers or classes:
void foo(const(char)[] str)
{
// valid since str is not final
// only changes local copy of array pointer and length
str = "abc";
// illegal! can't change the data of the array
str[] = "abc";
}
More information about the Digitalmars-d
mailing list