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

Chris Muller asqueaker at gmail.com
Wed Jul 3 18:27:32 UTC 2013


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?


More information about the Squeak-dev mailing list