argument of ifNotNil: must be a 0-argument block

Zulq Alam me at zulq.net
Fri Sep 1 23:25:07 UTC 2006


Hi List,

Why does "Object new ifNotNil: [:object | ]" result in the syntax error 
"argument of ifNotNil: must be a 0-argument block" when the code appears 
to be fine with this?


ProtoObject>>ifNotNil: ifNotNilBlock
	"Evaluate the block, unless I'm == nil (q.v.)"

	^ ifNotNilBlock valueWithPossibleArgs: {self}


BlockClosure>>valueWithPossibleArgs: anArray

	| n |
	(n := self numArgs) = 0 ifTrue: [^ self value].
	n = anArray size ifTrue: [^ self valueWithArguments: anArray].
	^ self valueWithArguments: (n > anArray size
		ifTrue: [anArray, (Array new: n - anArray size)]
		ifFalse: [anArray copyFrom: 1 to: n]): anArray



A quick search of Mantis for ifNotNil or valueWithPossibleArgs hasn't 
left me any wiser. Something to do with the interpreter, perhaps 
optimisation?

Thanks,
Zulq.




More information about the Squeak-dev mailing list