Personally, I would rather see #ifEmpty: modified to return self in the false case like #ifNil: does. The only in-image sender I can find that even uses the return value seems to actually expect this behaviour anyway. :) Then you could simply write: (aCollection select: [:ea | ...]) ifEmpty: [ ... ] Julian 2009/12/26 Bart Gauquie <bart.gauquie@gmail.com>:
Dear all,
While developing some code, I made following extension of the Collection protocol: select: aBlock ifNoneTakeAsDefault: aDefaultValue   |result|   result := self select: aBlock.   (result isEmpty)    ifTrue: [^self class with: aDefaultValue]    ifFalse: [^result].
Maybe this could be added to the Pharo 1.1 Collection clazz? Or do we want to keep the interface of Collection as small as possible (which is also a good idea!). Kind Regards, Bart -- imagination is more important than knowledge - Albert Einstein Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Albert Einstein The true sign of intelligence is not knowledge but imagination. - Albert Einstein Gravitation is not responsible for people falling in love. - Albert Einstein
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project