Loops and stuff (was Re: Python and Boehm-Demers GC, I have code.)
Tim Olson
tim at jumpnet.com
Fri Jul 23 07:41:01 EDT 1999
Markus Kohler wrote:
>
> Sorry my Smalltalk example is wrong.
> I must have coded for to long in this poor language called C ...
> I must look like this :
>
> do: aBlock
> a do:[:each | aBlock value: each]
> b do:[:each | aBlock value: each]
>
> more complicated but still very easy to understand.
No, your original code was fine:
do: aBlock
a do: aBlock.
b do: aBlock.
No need to wrap the incoming block in yet another block.
You could also write it as:
do: aBlock
a , b do: aBlock.
which might be even clearer.
-- Tim Olson
More information about the Python-list
mailing list