I find the selector name somewhat confusing, especially since we already have:
detect: aBlock ifFound: foundBlock ifNone: exceptionBlock
�� �� �� �� "Evaluate aBlock with each of the receiver's elements as the argument.
�� �� �� �� If some element evaluates aBlock to true, then cull this element into
�� �� �� �� foundBlock and answer the result of this evaluation.
�� �� �� �� If none evaluate to true, then evaluate exceptionBlock."
�� �� �� �� self
�� �� �� �� �� �� �� �� do: [ :each |
�� �� �� �� �� �� �� �� �� �� �� �� (aBlock value: each)
�� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� ifTrue: [ ^ foundBlock cull: each ] ].
�� �� �� �� ^ exceptionBlock value
On 20 May 2014, at 09:42, Tudor Girba <tudor@tudorgirba.com> wrote:
> Ah, yes :).
>
> Doru
>
>
> On Tue, May 20, 2014 at 9:38 AM, Stephan Eggermont <stephan@stack.nl> wrote:
> detect: aBlock ifOne: presentBlock ifNone: noneBlock
> �� �� �� �� | result |
> �� �� �� �� result := self detect: aBlock ifNone: [nil].
> �� �� �� �� ^ result isNil
> �� �� �� �� �� �� �� �� ifTrue: [ noneBlock value ]
> �� �� �� �� �� �� �� �� ifFalse: [ presentBlock value: result ]
>
> From CollectionExtensions in
>
> MCSmalltalkhubRepository
> �� �� �� �� owner: 'Moose'
> �� �� �� �� project: 'CollectionExtensions'
> �� �� �� �� user: ''
> �� �� �� �� password: ''
>
>
>
> --
> www.tudorgirba.com
>
> "Every thing has its own flow"