Introduction to OOP Chapter 19: Container Classes : next previous audio real text

Alternative, the Visitor

An alternative to iterators is the idea of a visitor. Requires the ability to bundle the action to be performed into an object, and hand it to the collection.

This is most common technique used in Smalltalk

aList do: [:x | ('element is' + x) print ].
The block is passed as argument to the list, which turns around and executes the block on each element.
Intro OOP, Chapter 19, Slide 18