ifNotNil:
Eric Arseneau
eat at huv.com
Fri Jun 16 20:36:14 UTC 2000
In VA, the ifNotNil: accepts an argument, which is the receiver, why does
Squeak not do this ?
I like the VA version since it allows you to write blocks which are light
weight, and also provides for cleaner code. Example
self someObject ifNotNil: [:object | object doSomething]
instead of
| temp |
temp := self someObject.
temp ifNotNil: [
temp doSomething].
The only way I can think of adding this is to do the following:
ifNotNil: ifNotNilBlock
"Evaluate the block, unless I'm == nil (q.v.)"
ifNotNilBlock numArgs = 0 ifTrue: [
^ifNotNilBlock value].
^ifNotNilBlock value: self
I hate code like this (note, this is done in Exception>>#handlerAction), but
I find that the extra functionality from the ifNotNil: to be too useful. I
could always use another name, but then what would that name be ?
Anybody have any thoughts on this ?
More information about the Squeak-dev
mailing list
|