"Lic. Edgar J. De Cleene" edgardec2001@yahoo.com.ar wrote: What you think of replacing. addAll: aCollection "Include all the elements of aCollection as the receiver's elements. Answer aCollection. Actually, any object responding to #do: can be used as argument." aCollection do: [:each | self add: each]. ^ aCollection with: addAll: aCollection "Include all the elements of aCollection as the receiver's elements. Answer aCollection. Actually, any object responding to #do: can be used as argument." aCollection ifNotEmptyDo: [:each | self add: each]. ^ aCollection I tired of fixing this kind or error . What error? The only error I see there is the one you've just introduced, where it is no longer true that 'any object responding to #do: can be used as argument.' What exactly is the problem you are trying to fix?
Or why not have a doSmart: ? "Evaluate aBlock with each of the receiver's elements as the argument always argument and element are both not empty or nil" I cannot understand this comment. All I can figure out for sure from the wording is that it is a complicated interface which I'm better off without.
On 06/12/04 00:26, "Richard A. O'Keefe" ok@cs.otago.ac.nz wrote:
What error? The only error I see there is the one you've just introduced, where it is no longer true that 'any object responding to #do: can be used as argument.' What exactly is the problem you are trying to fix?
Richard:
The error what I talking about is to try to add objects to a nil object. In image, in packages and of course my owns.
Sure what you could say what this never could reach exterior world and is a product of bad coding practices, but again, happens .
Sorry if was a silly question. And still don't understand way do: if for each element and ifNotNilDo: not.
Edgar
Am 06.12.2004 um 09:59 schrieb Lic. Edgar J. De Cleene:
And still don't understand way do: if for each element and ifNotNilDo: not.
Simple, #ifNotNilDo: is badly named. ...do: should imply iteration, but here it does not. We just have not found any equivalent, yet short, easy to remember, and intention revealing name. We had #ifNotNilIn: or #ifNotNilEval: but all that is much less readable than #ifNotNilDo:. I think Marcus suggested that #ifNotNil: could take an optional parameter, which I do like, but then the selector hardly communicates its intent. So ... if someone has a nice alternative, let's change it.
- Bert -
squeak-dev@lists.squeakfoundation.org