ifNotNil: perceived strangeness ;)

Zulq Alam me at zulq.net
Wed Oct 3 22:01:04 UTC 2007


This seems related to:
	
http://www.nabble.com/argument-of-ifNotNil:-must-be-a-0-argument-block-t2205353.html
http://bugs.squeak.org/view.php?id=4867

Regards,
Zulq.

Brian Brown wrote:
> Looking at ProtoObject>>ifNotNil: ifNotNilBlock
>     "Evaluate the block, unless I'm == nil (q.v.)"
> 
>     ^ ifNotNilBlock valueWithPossibleArgs: {self}ifNotNil:
> 
> 
> .... which is invoked if the receiver is not nil, I would expect the 
> following to work:
> 
> 5 ifNotNil: [:e |  e] to return 5, but what I get is:
>     
>     argument of ifNotNil: must be a 0-argument block
>     
>     
> However, if first store the block in a temp:
> 
>     ab := [:e | e]
> 
> 5 ifNotNil: ab.
> 
> 
> returns 5
> 
> I don't understand what the difference is between these; could some kind 
> soul enlighten me as what is happening?
> 
> 
> Cheers,
> 
> Brian
> 
> 
> 




More information about the Squeak-dev mailing list