|a lines|
a := #('quick' 'brown' 'fox').
"The following send >>subStrings to a String. The result of this is an
OrderedCollection with 5 elements, each element being a String. To get
an Array, we send >>asArray to the OrderedCollection."
a := 'Why are you teasing me?' subStrings asArray.
"In the next example I'm forcing the cr character into the string to
make the code work either from a code file, or in an image workspace.
The cr in a literal String *should* be respected, but in GNU Smalltalk
2.1.8 it does not seem to be in an image worksheet."
lines := (
('The boy stood on the burning deck.%1' bindWith: Character cr),
'It was as hot as glass.' subStrings: Character cr) asArray.
"Here we create a large array by reading the contents of a file. The
contents of the file is an instance of class String in this case.
>>contents is crude, but works fine in this case ... if you have
a file called 'mydatafile' in the current directory that contains
printable characters."
|bigArray|
bigArray := ((File name: 'mydatafile') contents) asArray.
"Now we concatenate some Strings and convert them to Arrays"
|name banner|
name := 'Gandalf'.
banner := ('Speak, ', name, ', and enter!') asArray.
banner := ('Speak, %1, and enter!' bindWithArguments: (Array with:
name)) asArray.
|