Strings
Meta: this page is mostly a method reference. Group by what you do with it; don't try to be exhaustive — link to Standard library reference for the full signatures.
Construction
- literals: see Literals
- concat:
+ - compound update:
s += "..." - template interpolation:
`hello ${name}`(see Literals)
Conversion
toString(value)— JSON-encodes non-strings; passes strings throughvalue :: String!— explicit cast where types align (see Types and nullability)
Inspection
Strings have no .length / .isEmpty methods — those are list methods (Collections). Use the predicates below.
s.contains(sub)s.hasPrefix(p)s.hasSuffix(p)
Case
s.toUppers.toLower
Trim and pad
s.trim(charset),s.trimLeft(charset),s.trimRight(charset),s.trimSpaces.trimPrefix(p),s.trimSuffix(p)s.padLeft(width),s.padRight(width),s.center(width)
Split / replace
s.split(separator),s.split(separator, limit: n)— empty separator splits into characters;limitcaps the number of parts (last part keeps the remainder)s.replace(old, new),s.replace(old, new, count: n)—countdefaults to -1 (replace all); emptyoldinserts between characters
Future: regex
Meta: see regexp.md for the planned Regexp scalar, Match object, and containsMatch/match/matchAll/replaceMatches/rewriteMatches/splitMatches family. Add a section here when it lands.