<div dir="ltr">I&#39;d go with the former, especially if the method is pretty short and there&#39;s only one test. In most cases I&#39;d probably be answering self, unless the nature of the method is such that it should answer something else (e.g., nil.)<div>
<br></div><div style>In general I find the early return to be idiomatic and familiar from a lot of other Smalltalk code, but to an extent this perception could be colored by a personal aesthetic preference, so YMMV. And I want the up-arrow glyph back, too :P</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 23, 2013 at 2:39 PM, Louis LaBrunda <span dir="ltr">&lt;<a href="mailto:Lou@keystone-software.com" target="_blank">Lou@keystone-software.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you everyone for your answers.<br>
<br>
Lou<br>
<div class="HOEnZb"><div class="h5"><br>
&gt;Kent Beck refers to the former as &quot;Guard Clause&quot; in his BP book and<br>
&gt;agrees with you about when to use it.<br>
&gt;<br>
&gt;I think it&#39;s good to only have returns at the top (guard clauses) or<br>
&gt;bottom.  Not in the middle.<br>
&gt;<br>
&gt;<br>
&gt;On Wed, Oct 23, 2013 at 9:12 AM, Louis LaBrunda<br>
&gt;&lt;<a href="mailto:Lou@keystone-software.com">Lou@keystone-software.com</a>&gt; wrote:<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m about to write a method where I need to test whether to do something or<br>
&gt;&gt; just get out.  What is the best practices way to do this?  For example:<br>
&gt;&gt;<br>
&gt;&gt; (a = b) ifTrue: [^nil].<br>
&gt;&gt; *The code that does the work*<br>
&gt;&gt;<br>
&gt;&gt; or:<br>
&gt;&gt;<br>
&gt;&gt; (a = b) ifFalse: [<br>
&gt;&gt;    *The code that does the work*<br>
&gt;&gt; ].<br>
&gt;&gt;<br>
&gt;&gt; I think the second is better style but I have used both.  Generally using<br>
&gt;&gt; the first when *The code that does the work* is long and the second when it<br>
&gt;&gt; is short.<br>
&gt;&gt;<br>
&gt;&gt; Is there any speed difference between them?  I doubt it but I thought I<br>
&gt;&gt; would ask anyway.<br>
&gt;&gt;<br>
&gt;&gt; Lou<br>
&gt;&gt; -----------------------------------------------------------<br>
&gt;&gt; Louis LaBrunda<br>
&gt;&gt; Keystone Software Corp.<br>
&gt;&gt; SkypeMe callto://PhotonDemon<br>
&gt;&gt; mailto:<a href="mailto:Lou@Keystone-Software.com">Lou@Keystone-Software.com</a> <a href="http://www.Keystone-Software.com" target="_blank">http://www.Keystone-Software.com</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
-----------------------------------------------------------<br>
Louis LaBrunda<br>
Keystone Software Corp.<br>
SkypeMe callto://PhotonDemon<br>
mailto:<a href="mailto:Lou@Keystone-Software.com">Lou@Keystone-Software.com</a> <a href="http://www.Keystone-Software.com" target="_blank">http://www.Keystone-Software.com</a><br>
<br>
<br>
</div></div></blockquote></div><br></div>