The first version:

(#(1 2 3) asSet collect: #odd)
do: [ :each | Transcript show: each; cr ]

is rather straight forward I believe, as collect: and do: has been around
forever (relatively speaking).


#(1 2 3) asSet collect: #odd
thenDo: [ :each | Transcript show: each; cr ]


On 8 September 2019 at 09.13.36, Richard Sargent (
richard.sarg...@gemtalksystems.com) wrote:

 I am skeptical of one that relies on a specific implementation rather than
a specific definition.

I share your feeling. I am not sure where such a definition would come
from. In Squeak it is defined as:

collect: collectBlock thenDo: doBlock

^ (self collect: collectBlock) do: doBlock

In pharo as:

collect: collectBlock thenDo: doBlock

^ self do: [ :each | doBlock value: (collectBlock value: each)]

I might have called the method collect:eachDo:, but we each have slightly
different styles. What I like about the pharo version is that is a
shorthand for something which is not achieved by mere parentheses.

Best,

Kasper

Reply via email to