A Text is an mutable sequence of Unicode characters (code points).

Note: A text literal (for example, "abc") is immutable and cannot be altered. Any attempt to do so simply fails, generating no error. To create a mutable text value from of a literal, clone it: +Text("abc").

Class Methods (see Type)

New
Creates a new text value. With no parameter, it creates an empty Text string. Otherwise, it converts the parameter to a Text value (applying .Text method to it). If the attempted conversion fails with null, an empty Text string is returned.

Instance Methods

<<
Append (push) the passed value (converted, if needed, to Text using .Text) to the end of 'self'
>>
Insert (or shift) the value(s) to the beginning of 'self'.
<=>
Compare two text values based on their unicode character code points. Returns 0 if equal, 1 if 'self' is greater, -1 if 'self' is less, and null if the passed value is not text.
+
Create a new Text value that concatenates 'self' with the passed string.
*
Create a new Text value that duplicates 'self' n times
[]
Get the character(s) specified by the indexed parameter. A single integer parameter selects the character at that position (starting with 0). If negative, it selects from the end of the text (-2 would be the last character). A second integer parameter specifies the last character desired (negative index allowed).

Set replaces the character(s) at the specified from and to integer indexes with the text string specified as the first parameter.

Clone
Create and return new Text that is a copy of 'self'.
Each
Returns an closure that iterates over the text value, returning the character index and a new Text value for the next sequential character each time it is called.
empty?
Return true if 'self' has no characters
Find
Return the index of the first character starting a sequence of characters matching the characters in the passed Text value. A second parameter can be given specifying which character to begin the find at.
Insert
Insert one or more values into the List starting at the index specified by the integer parameter. If the integer value is negative, it indexes relative to the end of the list.
Remove
Remove one or more values from the List starting at the index specified by an integer. If the integer value is negative, it indexes relative to the end of the list. A second parameter can specify the last character in the sequence to remove.
Replace
Replaces the character(s) at the specified from and to integer indexes with the text string specified as the first parameter.
size
Get (or set) the number of unicode characters held in the text value. One cannot set a size larger than the current size. Setting a smaller size effectively truncates characters off from the end.