[ENH] ifEmptyParam-md
marcus at ira.uka.de
marcus at ira.uka.de
Fri Jan 30 15:46:03 UTC 2004
from preamble:
"Change Set: ifEmptyParam-md
Date: 30 January 2004
Author: Marcus Denker
Julian Fitzell posted a changeset to add ifEmpty/ifNotEmpty methods to
Collection. This
is now part of 3.7a.
>From his changeset preamble:
--
There was some discussion and it was agreed that they should all take
0-arg blocks in all their forms and we could add #ifEmptyDo:, etc. at a
later point if desired.
--
Now there's a nice way of having ifEmpty: take both a 0-arg block (like
ifNotNil:)
and a 1-arg block (like ifNotNilDo:) by using valueWithPossibleArgs: to
double-dispatch on
the number of arguments in the block.
ifNotEmpty: aBlock
^self isEmpty ifFalse: [aBlock valueWithPossibleArgs: {self}].
enabeling both
#(1) ifNotEmpty: [:i | i first]
#(1) ifNotEmpty: ['hello']
This changeset changes ifNotEmpty:/ifNotEmpty:ifEmpty and
ifEmpty:ifNotEmpty to use
valueWithPossibleArgs.
I think it would be good to have the ifNotNil inlining and the methods
to take
both 0-Arg and 1-Arg blocks, too. I will look into this later.
"!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ifEmptyParam-md.cs.gz
Type: application/octet-stream
Size: 792 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040130/1733b177/ifEmptyParam-md.cs.obj
More information about the Squeak-dev
mailing list
|