ifTrue: ~~ ifNil:

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Wed Apr 12 09:23:27 UTC 2000


On Tue, 11 Apr 2000, Andres Valloud wrote:

> Is there an important reason for the fact that [...]
>     anObject ifNil: [false]
> evaluates to anObject?

The intent for #ifNil: was not to parallel #ifTrue:, but the most common 
use is defaulting, like in 
	(self getValue ifNil: [Default]) doSomething
which saves you a temp var.

>From this intent derived the definition:

	For all of the following messages:
		#ifNil: #ifNotNil: #ifNil:ifNotNil: #ifNotNil:ifNil:
	If the receiver is nil, then answer the value of the corresponding
	parameter block if there is one, otherwise answer self.

Is this already in the image? It is in mine ...

(Now, did I say yes were Dan said no? Oops! :-))

  -Bert-






More information about the Squeak-dev mailing list