|
CollectorsA useful kind of object when building a collection is a collector. A collector is a node in a linked list of collectors.All objects that inherit from defaultBehavior respond to the binary message & by making a new collector list containing the receiver and argument. Collectors respond to & by appending the argument to the list. Collector lists can be converted to the other kinds of collections using asList, asSequence, asSet, etc. Hence, a convenient way to make a collection from literal objects is using collectors:
(1 & false & nil & 'foo') asVectorBecause the & operation is fast, a collector is also a useful way of accumulating all the elements of a collection before actually constructing the collection.
|