1. Strings


"In Smalltalk, everything is an object.  Including strings.  Strings are
instances of the class String."

string := '\n'.  "Two Characters, \ and an n - literal form"
string := String with: $\ with: $n.  "As above, but creating the string
by passing messages"
string := 'Jon ''Maddog'' Orwant'.  "Literal string containing single
string := String with: Character cr.  "String with a newline character"
string := 'Jon "Maddog" Orwant'.  "Literal string containing double

"ANSI standard Smalltalk does not allow arbitrary literal string

"Reading a stream of characters up to (but not including) 'EOF'.  Most
String handling in Smalltalk is done using streams (instances of class
Stream or one of its subclasses."

|sourceStream a|
sourceStream := ReadStream on: 'This is a multiline here document
terminated by EOF on a line by itself
a := sourceStream upToAll: 'EOF'.

Accessing Substrings

Establishing a Default Value

Exchanging Values Without Using Temporary Variables

Converting Between ASCII Characters and Values

Processing a String One Character at a Time

Reversing a String by Word or Character

Expanding and Compressing Tabs

Expanding Variables in User Input

Controlling Case

Interpolating Functions and Expressions Within Strings

Indenting Here Documents

Reformatting Paragraphs

Escaping Characters

Trimming Blanks from the Ends of a String

Parsing Comma-Separated Data

Soundex Matching

Program: fixstyle

Program: psgrep