ifNotNil:
Florin X Mateoc
mateoc_florin at jpmorgan.com
Fri Jun 16 21:06:09 UTC 2000
I think the appropriate name would be #do:
Object>>do: would be
aBlock value: self
UndefinedObject>>do: would be a noop
But I suspect many people would object to this, so perhaps #ifNotNilDo: would do
eat at huv.com on 06/16/2000 04:36:14 PM
Please respond to squeak at cs.uiuc.edu
To: squeak at cs.uiuc.edu
cc: (bcc: Florin X Mateoc)
Subject: ifNotNil:
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 ?
This communication is for informational purposes only. It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan & Co. Incorporated, its
subsidiaries and affiliates.
More information about the Squeak-dev
mailing list
|