On Tue, 30 Jun 2009 07:15:37 +0200, Igor Stasenko wrote:
Since multiple people seem don't grok my example, let me simplify it a bit:
Suppose you have a special collection of objects over which you can iterate.
The items in that collection could be anything - you don't really care on almost any of them, except those ones which is also a special collections of same kind as a container.
so, then you could have a method, which by iterating through your special collection, ignores all objects except those who also can be iterated in same manner:
MySpecialCollection>>mySpecialCollect: aBlock ^ self collect: [:each | each isMySpecialCollection ifTrue: [ each mySpecialCollect: aBlock] ifFalse: [each] ]
In _any_ Smalltalk, (each respondsTo: #mySpecialCollect:) is what you want.