Look like #ifNotEmpty: is the correct choice.

Collection methods select: [ :m |
               (m selector          includesSubstring: 'if' caseSensitive: 
false) and: [
                              m selector includesSubstring: 'empty' 
caseSensitive: false
               ]
]
thenCollect: [ :m | m -> m senders size ]

"{
               Collection>>#ifEmpty:->188.
               Collection>>#ifNotEmpty:->113.
               Collection>>#ifNotEmptyDo:ifEmpty:->0.
               Collection>>#ifEmpty:ifNotEmpty:->80.
               Collection>>#ifEmpty:ifNotEmptyDo:->0.
               Collection>>#ifNotEmptyDo:->0.
               Collection>>#ifNotEmpty:ifEmpty:->14
}"

Best regards,
Henrik

From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of 
Peter Uhnák
Sent: Saturday, October 10, 2015 6:55 PM
To: Pharo Users List <pharo-users@lists.pharo.org>
Subject: [Pharo-users] ifNotEmpty(Do):

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"

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 smalltalks?)

Thanks,
Peter


Reply via email to