public final class MutableString
Mutable Unicode text with reference identity. Ordinary string literals and toString() produce immutable String values; m"text" creates a MutableString. Assigning an alias preserves identity, and edits remain visible through it. A String snapshot remains unchanged by later edits, even through reflection. Size and indexing count Unicode scalars; codeUnits exposes a UTF-16 copy.
text = m"Klyn" snapshot = text.toString() alias = text text[0] = 'k' assert alias == "klyn" and snapshot == "Klyn"
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | codePointscodePoints as Char[] |
Independent array of Unicode scalar values. |
| public readonly property | codeUnitscodeUnits as CodeUnit[] |
Independent array of UTF-16 code units. |
| public readonly property | isEmptyisEmpty as Boolean |
Whether the text is empty. |
| public readonly property | sizesize as ULong |
Number of Unicode scalar values. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | MutableStringMutableString(notnull value as Char[]) |
Creates mutable text using the String conversion rules. |
| public | MutableStringMutableString(notnull value as CodeUnit[]) |
Creates mutable text using the String conversion rules. |
| public | MutableStringMutableString(notnull value as MutableString) |
Copies the value of another instance; later edits remain independent. |
| public | MutableStringMutableString(notnull value as String = "") |
Initializes editable text from an immutable String snapshot. |
| public | MutableStringMutableString(value as Char) |
Creates mutable text using the String conversion rules. |
| public | MutableStringMutableString(value as CodeUnit) |
Creates mutable text using the String conversion rules. |
| public | MutableStringMutableString(value as Object) |
Creates mutable text using the String conversion rules. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | _slice | Implements scalar-based slicing while preserving omitted bounds. |
| public static | _sliceAssign | Internal helper used by the compiler to implement string slice assignment. |
| public | capitalizecapitalize() as MutableString |
Capitalizes the string in place (first character only). |
| public | center | Returns immutable padded text, or the current snapshot if no padding is needed. |
| public | countcount(notnull value as MutableString) as ULong |
Queries text without changing it. |
| public | count | Queries text without changing it. |
| public | count | Counts a Unicode scalar in one forward traversal of an immutable snapshot. |
| public | endsWithendsWith(notnull value as MutableString) as Boolean |
Queries text without changing it. |
| public | endsWith | Queries text without changing it. |
| public | endsWithendsWith(notnull values as IList<MutableString>) as Boolean |
Tests whether any supplied text matches. |
| public | endsWith | Tests whether any supplied text matches. |
| public | endsWith | Tests a scalar suffix without modifying this mutable text. |
| public | equalsIgnoreCaseequalsIgnoreCase(notnull value as MutableString) as Boolean |
Queries text without changing it. |
| public | equalsIgnoreCase | Queries text without changing it. |
| public static | fromCodePointfromCodePoint(value as Int) as MutableString |
Creates a Unicode scalar from its integer value and snapshots its text. |
| public override | hashhash() as Long |
Returns a content hash, equal to the hash of equivalent String text. |
| public | indexOfindexOf(notnull value as MutableString, start as Long = 0) as Long |
Queries text without changing it. |
| public | indexOf | Queries text without changing it. |
| public | indexOf | Finds the first occurrence of a Unicode scalar. |
| public | isAlnumisAlnum() as Boolean |
Tests whether the non-empty text consists entirely of Unicode letters or digits. |
| public | isAlphaisAlpha() as Boolean |
Tests whether the non-empty text consists entirely of Unicode letters. |
| public | isBlankisBlank() as Boolean |
Tests whether the text is empty or consists entirely of whitespace. |
| public | isDigitisDigit() as Boolean |
Tests whether the non-empty text consists entirely of Unicode digits. |
| public | isLowerisLower() as Boolean |
Tests whether all cased characters are lowercase, with at least one cased character. |
| public | isSpaceisSpace() as Boolean |
Tests whether the non-empty text consists entirely of Unicode whitespace. |
| public | isUpperisUpper() as Boolean |
Tests whether all cased characters are uppercase, with at least one cased character. |
| public | join | Joins a read-only list without modifying its elements. |
| public | join | Joins UTF-16 code units without splitting supplementary characters. |
| public | joinjoin(notnull values as IList<MutableString>) as String |
Joins a read-only list without modifying its elements. |
| public | join | Joins a read-only list without modifying its elements. |
| public | lastIndexOflastIndexOf(notnull value as MutableString, start as Long = -1) as Long |
Queries text without changing it. |
| public | lastIndexOf | Queries text without changing it. |
| public | lastIndexOf | Finds the last occurrence of a Unicode scalar. |
| public | lines | Splits CR, LF and CRLF lines without retaining line terminators. |
| public | lowerlower() as MutableString |
Converts the string to lowercase in place. |
| public | lpad | Returns immutable padded text, or the current snapshot if no padding is needed. |
| public | ltrimltrim() as MutableString |
Removes leading whitespace in place. |
| public | matches | Tests the complete text against a regular expression. |
| public | removeAccentsremoveAccents() as MutableString |
Removes accents in place. |
| public | removeSGRremoveSGR() as String |
Returns an immutable text transformation without modifying this instance. |
| public | replacereplace(notnull oldValue as MutableString, notnull newValue as MutableString) as String |
Returns an immutable String with substring replacements. |
| public | replace | Returns a replacement snapshot without modifying this mutable text. |
| public | replace | Returns an immutable String with substring replacements. |
| public | replace | Returns a replacement snapshot without modifying this mutable text. |
| public | replace | Returns a replacement snapshot without modifying this mutable text. |
| public | replaceFirstreplaceFirst(notnull oldValue as MutableString, notnull newValue as MutableString) as String |
Returns an immutable String with substring replacements. |
| public | replaceFirst | Returns a single-replacement snapshot without modifying this mutable text. |
| public | replaceFirst | Returns an immutable String with substring replacements. |
| public | replaceFirst | Returns a single-replacement snapshot without modifying this mutable text. |
| public | replaceFirst | Returns a single-replacement snapshot without modifying this mutable text. |
| public | replaceLastreplaceLast(notnull oldValue as MutableString, notnull newValue as MutableString) as String |
Returns an immutable String with substring replacements. |
| public | replaceLast | Returns a single-replacement snapshot without modifying this mutable text. |
| public | replaceLast | Returns an immutable String with substring replacements. |
| public | replaceLast | Returns a single-replacement snapshot without modifying this mutable text. |
| public | replaceLast | Returns a single-replacement snapshot without modifying this mutable text. |
| public | rpad | Returns immutable padded text, or the current snapshot if no padding is needed. |
| public | rtrimrtrim() as MutableString |
Removes trailing whitespace in place. |
| public | split | Splits a snapshot at a Unicode scalar without modifying this mutable text. |
| public | splitsplit(notnull delimiter as MutableString) as ArrayList<String> |
Splits text into immutable String segments stored in a mutable list. |
| public | split | Splits text into immutable String segments stored in a mutable list. |
| public | startsWithstartsWith(notnull value as MutableString) as Boolean |
Queries text without changing it. |
| public | startsWith | Queries text without changing it. |
| public | startsWithstartsWith(notnull values as IList<MutableString>) as Boolean |
Tests whether any supplied text matches. |
| public | startsWith | Tests whether any supplied text matches. |
| public | startsWith | Tests a scalar prefix without modifying this mutable text. |
| public | titletitle() as MutableString |
Capitalizes each word in place. |
| public | toCapitalizetoCapitalize() as String |
Returns an immutable text transformation without modifying this instance. |
| public | toCharArraytoCharArray() as Char[] |
Copies characters into an independently mutable array. |
| public | toCodeUnitArraytoCodeUnitArray() as CodeUnit[] |
Copies characters into an independently mutable array. |
| public | toLowertoLower() as String |
Returns an immutable text transformation without modifying this instance. |
| public | toRemoveAccentstoRemoveAccents() as String |
Returns an immutable text transformation without modifying this instance. |
| public override | toStringtoString() as String |
Returns an immutable snapshot; subsequent edits do not change it. |
| public | toTitletoTitle() as String |
Returns an immutable text transformation without modifying this instance. |
| public | toTrimtoTrim() as String |
Returns an immutable text transformation without modifying this instance. |
| public | toUppertoUpper() as String |
Returns an immutable text transformation without modifying this instance. |
| public | trimtrim() as MutableString |
Removes leading and trailing whitespace in place. |
| public | upperupper() as MutableString |
Converts the string to uppercase in place. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | operator in(notnull value as MutableString) as Boolean | Tests substring membership. |
| public | operator in(notnull value as String) as Boolean | Tests substring membership. |
| public | operator in(value as Char) as Boolean | Tests scalar membership without converting integers or unrelated objects to text. |
| public static | operator*(first as MutableString, count as ULong) as String | Repeats mutable text. |
| public | operator*=(count as ULong) as MutableString | Repeats the content in place. |
| public static | operator+(first as MutableString, second as MutableString) as String | Concatenates mutable text. |
| public | operator+=(notnull value as MutableString) as MutableString | Appends another mutable value, including this instance itself. |
| public | operator+=(value as Char) as MutableString | Appends one Unicode scalar, not its quoted debug representation. |
| public | operator+=(value as CodeUnit) as MutableString | Appends one UTF-16 unit representing a BMP character. |
| public | operator+=(value as String) as MutableString | Appends text without changing the identity of this mutable instance. |
| public | operator==(other as Object) as Boolean | Compares textual content without converting unrelated objects. |
| public | operator[](position as Long) as Char | Returns the Unicode scalar at an index; negative indices count from the end. |