Chronos is one of the many Smalltalk-related blogs syndicated on Planet Smalltalk

Discussion of the Essence# programming language, and related issues and technologies.

Blog Timezone: America/Los_Angeles [Winter: -0800 hhmm | Summer: -0700 hhmm] 
Your local time:  


Doing without

Reading a recent post by Ramon Leon, a thought occurred to me: In many cases, there's a better alternative to using #copyWithout:. The alternative would be to use #do:without:, implemeted as follows:

    do: block1 without: anElement
        self do: [:each | each = anElement ifFalse: [block1 value: each]]
The advantage should be obvious: It avoids making a "throw away" copy of the initial collection.

No comments: