[squeak-dev] Future of Squeak, and outsider's view

Igor Stasenko siguctua at gmail.com
Tue Jun 30 05:18:39 UTC 2009


2009/6/30 Igor Stasenko <siguctua at gmail.com>:
> 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]
>      ]
>

oops. looks like aBlock is not used :)
Okay.. how about that:

MySpecialCollection>>mySpecialCollect: aBlock
   | copy |
  copy := self collect: [:each |
          each isMySpecialCollection ifTrue: [ each mySpecialCollect:
aBlock] ifFalse: [each]
     ].
  ^ aBlock value: copy


> --
> Best regards,
> Igor Stasenko AKA sig.
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list