Help - Glossary - C - Collections

Collections are the workhorse of Squeak and Smalltalk. They come in several kinds and subkinds. A very useful kind of Collection is the OrderedCollection. This can be used to add any object to it at any place in it. Thus OrderedCollections can act like an array, a stack, a queue or a sequence.

| oc |
oc := OrderedCollection new.
oc add: 'The first object'.
oc add: '2 asInteger'.
oc add: (1/3).
oc inspect

OrderedCollections work with integers as keys. If you want keys that may be any object, including strings or symbols use a Dictionary. You can convert OrderedCollections using the methods asSet, asSortedCollection and asSortedCollection: (where the last allows adding a sort block).

Glossary - C