[squeak-dev] did ifEmpty:ifNotEmpty: change?

Chris Muller ma.chris.m at gmail.com
Fri Mar 12 21:05:22 UTC 2010


I know the semantics of ifEmpty: and ifNotEmpty: changed in the trunk
image last year, to answer the receiver instead of nil in the other
case.

However, I also noticed ifEmpty:ifNotEmpty: changed but I'm not seeing
any semantic difference.  Is there some subtlety I'm missing by the
new:

ifEmpty: emptyBlock ifNotEmpty: notEmptyBlock
	"Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise"
	" If the notEmptyBlock has an argument, eval with the receiver as its argument"

	self isEmpty ifTrue: [ ^emptyBlock value ].
	^notEmptyBlock valueWithPossibleArgument: self

vs. old:

ifEmpty: emptyBlock ifNotEmpty: notEmptyBlock
	"Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise"
	" If the notEmptyBlock has an argument, eval with the receiver as its argument"

	^ self isEmpty ifTrue: emptyBlock ifFalse: [notEmptyBlock
valueWithPossibleArgument: self]

?

Thanks,
  Chris



More information about the Squeak-dev mailing list