"Arrays are also objects in Smalltalk.
The class Array is a subclass (though not an immediate subclass) of
Collection. All collections share enumeration and mutation abilities,
though some kinds of collection impose limits. For example, Arrays are
of a fixed size, so it is not possible to add more elements to an Array
than it's current size - with other kinds of collection, any number of
elements can be added (until you hit a system limit, like running out of
memory).""Arrays have a literal form, unlike other kinds of collection."
|myArray|
"First we assign a litteral Array containing four Strings to the
variable myArray."
myArray := #('this''that''the''other').
"Now we create a nested Array in a similar way. We end up with an Array
with three elements, the first two being Strings and the third being a
distinct instance of class Array in turn containing two Strings."
myArray := #('this''that' #('the''other')).
"We can also create arrays by message passing. So, to repeat the last
last example:"
|outer nested|
nested :=Arraywith:'the'with:'other'.
outer :=Arraywith:'this'with:'that'with: nested.

|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 :=((Filename:'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:(Arraywith:
name)) asArray.