Not only isn't it easier to understand, it's harder. With collections "do:" normally means enumeration (do:, allButLastDo:, reverseDo:), but ifNotEmptyDo: doesn't enumerate the receiver.
Sent: Sunday, October 11, 2015 at 5:29 AM From: "Marcus Denker" <marcus.denker@inria.fr> To: "Any question about pharo is welcome" <pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] ifNotEmpty(Do):
On 10 Oct 2015, at 18:55, Peter Uhnák <i.uhnak@gmail.com> wrote:
Collection>>ifNotEmpty: comment says
"If the block has an argument, eval with the receiver as its argument, but it might be better to use ifNotEmptyDo: to make the code easier to understand"
We should update the comment. I think the comment is wrong: there is nothing more easier to understand with # ifNotEmptyDo: vs. # ifNotEmpty.
yet when I do that, Code Critic complains: ifNotEmptyDo: should not be used as ifNotEmpty: works for blocks with arguments, too.
1) who is right? what should I use? 2) shouldn't one be deprecated then? (or maybe one of them is to be compatible with other smalltalk?)
We did not deprecated as this is used a lot in old code⦠we should move it to a compatibility package.
Marcus