[squeak-dev] removing from a collection while enumerating it

Bert Freudenberg bert at freudenbergs.de
Wed Jul 3 21:19:45 UTC 2013


On 03.07.2013, at 11:27, Chris Muller <asqueaker at gmail.com> wrote:

> I have a case where I need to remove certain entries from an
> OrderedCollection that will be called very frequently.  I therefore
> want to avoid copying the collection (to safely remove while
> enumerating) but it seems #reverseDo: can do what I want.
> 
>  myCollection reverseDo: [ : each | each meetsSomeCriteria ifTrue: [
> myCollection remove: each ] ]
> 
> Does anyone see any problem with doing this?

What's wrong with removeAllSuchThat:?

- Bert -




More information about the Squeak-dev mailing list