Doing without
Labels:
collections,
programming,
Smalltalk
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: anElementThe advantage should be obvious: It avoids making a "throw away" copy of the initial collection.
self do: [:each | each = anElement ifFalse: [block1 value: each]]
No comments:
Post a Comment