Removing elements while Iterating over a collection?
Filip Stádník
filda at senior.cz
Mon Mar 21 23:50:28 UTC 2005
Hello Squeakers,
can anybody kindly explain me whether the following code has or has not the
Classic Smalltalk Bug
i.e."Removing elements while iterating over a Collection" or why is it so?
---------------------------------------------------------
Scheduler>>processAnimations
"This method processes any active Animations and removes any that are
completed."
animationList do: [:anim | anim update: currentTime.
(anim isDone) ifTrue: [self removeAnimation: anim]
].
----------------------------------------------------------
Scheduler>>removeAnimation: anAnimation
"Remove an animation from the Scheduler's list of animations"
animationList remove: anAnimation ifAbsent: [].
----------------------------------------------------------
Am I missing anything very important here?
Is this a kind of optimization?
Thanks for your answers.
Filip Stadnik
More information about the Squeak-dev
mailing list
|