But that does't work in the case the object you are looking for nil... (Ok, maybe that's not a really relevant case...) This version however handles the case, detect: aBlock ifOne: presentBlock ifNone: noneBlock | result | result := self detect: aBlock ifNone: [ ^ noneBlock value ]. ^ presentBlock value: result Guille 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: ''