The String object seems fairly useless. Apparently it corresponds to the empty string "". Adding methods to it does not affect other strings. Instead, use Sequence.
A String is basically a list of characters, which are represented as bytes. Unlike Python, when you get a character at a given position, you get a byte, not a string with length 1.
Some string methods expect a mutable string, even though strings are immutable by default! For example, the strip methods. To remedy this, use asMutable, then call the desired method. (E.g. " abc " asMutable strip)
Getting the length of a string:
"abc" size #=> 3
Checking if a string contains a substring:
"apples" containsSeq("ppl")
#=> true
Getting the character (byte) at position N:
"Kavi" at(1) #=> 97
Slicing:
Io> "Kirikuro" slice(0, 2) #=> "Ki" Io> "Kirikuro" slice(-2) # NOT: slice(-2, 0)! #=> "ro" Io> "Kirikuro" slice(0, -2) # "Kiriku"
Stripping whitespace:
" abc " asMutable strip # "abc" # also: lstrip, rstrip
Converting to upper/lowercase:
"Kavi" asUppercase #=> "KAVI" "Kavi" asLowercase #=> "kavi"
Splitting a string:
Io> "the quick brown fox" split
#=> list("the", "quick", "brown", "fox")
# splitting by other character is possible as well:
Io> "a few good men" split("e")
#=> list("a f", "w good m", "n")
Converting to number:
"13" asNumber #=> 13 "13a" asNumber #=> 13 "a13" asNumber #=> nil
String interpolation:
Io> name := "Fred"
#=> Fred
Io> "My name is #io{name}" interpolate
#=> My name is Fred
Why the "#io" part? Explanation:
<zephyrfalcon> Why does it say #io{something}, though? What's the 'io' for?
<jer> zephyrfalcon, its to tell the interpolation code that the code you're evaluating is io code
<zephyrfalcon> Are other values possible besides 'io'?
<jer> zephyrfalcon, when i wrote interpolation support, it was my goal to also allow interpolation of other languages code (if you have defined a path to an interpreter for it) ... but right now, i havn't written that support yet, due to lack of other support (popen would work, but not portable)