<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>
&gt; Date: Wed, 25 Jul 2007 16:58:49 +0100<br>&gt; From: keith_hodges@yahoo.co.uk<br>&gt; To: squeak-dev@lists.squeakfoundation.org<br>&gt; Subject: Message Eating Null - article<br>&gt; <br>&gt; To contrast this, how then would you have to code it if nil has the <br>&gt; "exception throwing" behavior? You would do<br>&gt; it similar to this:<br>&gt; <br>&gt;   | tmp |<br>&gt;    tmp := person office.<br>&gt;    tmp notNil ifTrue: [tmp := tmp phone].<br>&gt;    tmp notNil ifTrue: [tmp := tmp lastNumberDialed].<br>&gt;    tmp notNil ifTrue: [lastNumber := tmp asString].<br>&gt;    widget setStringValue: lastNumber.<br>&gt; <br>&gt; Yuck...all those explicit tests for nil are really ugly! Of course, you <br>&gt; could have instead wrapped the original code<br>&gt; in an exception handler, and thus avoided the nil tests, something like <br>&gt; as follows:<br>&gt; <br>&gt;    [lastNumber := person office phone lastNumberDialed asString.<br>&gt;    widget setStringValue: lastNumber]<br>&gt;       on: Object messageNotUnderstoodSignal do: [].<br>&gt; <br>&gt; This looks a bit simpler than the previous example, but even this <br>&gt; example contrasts poorly to the first example.<br>&gt; The first example of these three is much simpler! You just "do it", <br>&gt; without worrying about exceptions, exception<br>&gt; handlers, or explicit tests.<br><br>Yuck, I wouldn't do either of those.&nbsp; I would do:<br><br>widget setStringValue: #(office phone lastNumberDialed asString) inject: person into: [:obj :sel| o == nil ifTrue: [ nil ] ifFalse: [ obj sel ] ]<br><br /><hr />Local listings, incredible imagery, and driving directions - all in one place! <a href='http://maps.live.com/?wip=69&FORM=MGAC01' target='_new'>Find it!</a></body>
</html>