[ANSI-Smalltalk] Re: A list of interesting methods, ifNotNil:
Richard A. O'Keefe
ok at cs.otago.ac.nz
Mon Sep 8 05:09:48 BST 2008
On 5 Sep 2008, at 5:33 pm, Paolo Bonzini wrote:
> I'll just point out that #ifNotEmptyDo:, for me is a shortcut for
>
> x isEmpty ifTrue: [ x do: monadicBlock ]
>
> which is a good reason for supporting bi-arity instead of overloading
> the meaning of "do".
I am now confused.
The actual code in Squeak is
ifNotEmptyDo: aBlock
^self isEmpty ifTrue: [aBlock value: self]
It certainly doesn't involve any sending of the message #do:.
x isEmpty ifTrue: [x do: monadicBlock]
would, if x is a collection, never do anything at all with monadicBlock.
I take it that this should have been
x isEmpty ifFalse: [x do: monadicBlock]
and there is a name for that too: #do:.
VisualWorks also has an if*Do: method or two.
GeneralBindingReference>>ifDefinedDo:
has nothing to do with #do:.
WindowManager>>activeControllerProcessIfBlockedDo:
also has nothing to do with #do:.
More information about the ANSI-Smalltalk
mailing list