[Newbies] Re: Re: error trap
Damien Cassou
damien.cassou at laposte.net
Sun Aug 13 16:31:23 UTC 2006
> Yes. And, into the other direction, even in good core methods one often
> finds things like
>
> ^ dict at: aKey ifAbsent: [nil]
>
> There seems to be a "natural" confusion between "object" value and block
> "value".
What's the problem with that ? Yes, 'nil value' answers nil but 'nil' is
not a block and #at:ifAbsent: waits for a block (the parameter is called
aBlock). It is shorter to write 'nil' directly I agree.
What is more problematic in my point of view is code like this:
AbstractLauncher>>parameterAt: parName ifAbsent: aBlock
"Return the parameter named parName.
Evaluate the block if parameter does not exist."
^self parameters
at: parName asUppercase
ifAbsent: [aBlock value]
It may be me (still a beginner), but it looks equivalent to
^self parameters
at: parName asUppercase
ifAbsent: aBlock
which is faster and clearer in my opinion.
More information about the Beginners
mailing list