<div dir="ltr"><br><br><div class="gmail_quote">On Fri, Aug 8, 2008 at 5:37 PM, tim Rowledge <span dir="ltr">&lt;<a href="mailto:tim@rowledge.org">tim@rowledge.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d"><br>
On 8-Aug-08, at 5:20 PM, Igor Stasenko wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2008/8/9 Craig Latta &lt;<a href="mailto:craig@netjam.org" target="_blank">craig@netjam.org</a>&gt;:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
 &nbsp; I&#39;ll ask the inevitable question... given that ability, what do you<br>
really want to do? :)<br>
<br>
</blockquote>
<br>
Some practicle usage: pick an arbitrary array and tell the number of<br>
_unique_ objects it contains, including nils, of course.<br>
</blockquote>
<br>
<br></div>
For Sets that is trivial without any need whatsoever to alter anything. It is theSet size + 1 since all Sets will have at least one nil. Unless of course some evil person messes up the growing protocol for Sets.</blockquote>
<div><br></div><div>But it doesn&#39;t deal with the case where the array includes nil. &nbsp;So one has to come up with something clumsy such as</div><div><br></div><div>&nbsp;&nbsp; &nbsp;(theArray select: [:obj| obj notNil]) asSet size + ((theArray includes: nil) ifTrue: [1] ifFalse: [0])</div>
<div><br></div><div>which creates an extra collection for the select, requires an extra pass to find nil (n the case where it doesn&#39;t contain it) and is plain ugly&nbsp;</div><div><div>or</div><div>&nbsp;&nbsp; &nbsp;[| forNil |&nbsp;forNil&nbsp;:= 0. (theArray inject: Set new into: [:set :item| item == nil ifTrue: [hasNil := 1] ifFalse: [set add: item]. set]) + forNil]</div>
<div>which is faster but even more verbose and confusing.</div><div><br></div></div><div>Compare this to<br></div><div><br></div><div>&nbsp;&nbsp; &nbsp;theArray asSet size</div><div><br></div><div>I&#39;m with Igor. &nbsp;This would indeed be an improvement.</div>
<div><br></div><div>Just because &quot;its always been this way&quot; doesn&#39;t mean its right.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="Ih2E3d">
<br>
<br>
tim<br>
--<br>
tim Rowledge; <a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" target="_blank">http://www.rowledge.org/tim</a><br></div>
Variables won&#39;t; constants aren&#39;t.<br>
<br>
<br>
<br>
</blockquote></div><br></div>