(no subject)
Andrew P. Black
black at cs.pdx.edu
Fri Apr 7 20:03:52 UTC 2006
Does anyone else feel that
x ifNotNilDo: [: each | Transcript show: each; space]. (1)
and
x ifNotNil: [ x do: [: each | Transcript show: each; space]]. (2)
ought to do the same thing?
Or perhaps nil should respond to do: (and do nothing?)
The rationale is to be able to use instance variables initialized to
nil as empty collections, without having to repeatedly test if they
are nil before telling them to do: something, as in phrase (2)
above. One might be forgiven for thinking that ifNotNilDo: would
have the same effect as do: on a non-nil object.
I realize that it is probably infeasible to make a change like this,
but I couldn't resist thinking about it.
Andrew
More information about the Squeak-dev
mailing list
|