[BUG]Collection>>removeAll:
Richard A. O'Keefe
ok at cs.otago.ac.nz
Thu Aug 22 02:47:33 UTC 2002
Ralph Johnson <johnson at cs.uiuc.edu> wrote:
By the way, the way I'd write removeAll is
removeAll
[self isEmpty] whileFalse: [self removeAll: self]
You are assuming that (self removeAll: self) can only fail by
being incomplete. It is not obvious that this is the case for
all collections in the system, and it is far from obvious that
it will be so for other collections (if they have the same bug).
Put it in Collection and perhaps that would solve your problem.
The safest thing to put in Collection would be
removeAll
[self isEmpty] whileFalse: [self remove: self anyOne]
I do not say the most efficient, only the safest.
More information about the Squeak-dev
mailing list
|