class operator Assign(var Dest: Substring; const [ref] Src: Substring);
Assignment: the target holds the same text.
Result: stored in self (calling object)
Remarks:
A short text is copied, and the copy holds only s's characters: its Index is 1. A copy of a long text or of an adopted string shares its characters with s, and its Index is s's, so a write inside the text of one (s[i] :=, UpperCaseAscii, LowerCaseAscii) is seen by the other; MakeUnique gives a string its own copy first.
Examples
A short copy is separate; a long copy shares its characters until MakeUnique.
uses Substr;
procedure Example;
var s, t: Substring;
begin
s := Substring('abc');
t := s;
t[0] := 'X';
Assert(s = 'abc');
Assert(t = 'Xbc');
s := Substring.Create('a', 600);
t := s;
t[0] := 'b';
Assert(s[0] = 'b');
t.MakeUnique;
t[0] := 'c';
Assert(s[0] = 'b');
end;
See Also: Substring.MakeUnique