ifNotNil: perceived strangeness ;)
Brian Brown
rbb at techgame.net
Wed Oct 3 16:13:28 UTC 2007
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
|