<br><br><div class="gmail_quote">On Tue, Feb 22, 2011 at 9:59 AM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Tue, 22 Feb 2011, Eliot Miranda wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, Feb 21, 2011 at 9:37 PM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt; wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, 21 Feb 2011, Eliot Miranda wrote:<br>
<br>
snip<br>
<br>
<br>
 Actually, thinking a little, why not<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Collection &gt;&gt; join: delimiter<br>
<br>
     ^self species streamContents: [ :stream |<br>
             self<br>
                     do: [ :each | each putOn: stream ]<br>
                     separatedBy: [ delimiter putOn: stream ] ]<br>
<br>
?<br>
<br>
</blockquote>
<br>
Because I&#39;d like this:<br>
#(&#39;foo&#39; &#39;bar&#39; &#39;baz&#39;) join: $-<br>
to return this:<br>
&#39;foo-bar-baz&#39;<br>
rather than this:<br>
#($f $o $o $- $b $a $r $- $b $a $z).<br>
<br>
</blockquote>
<br>
So then why not<br>
<br>
SequenceableCollection &gt;&gt; join: delimiter<br>
<br>
      ^self isEmpty<br>
          ifTrue: [ self ]<br>
          ifFalse:<br>
               [ self first species streamContents:<br>
                    [ :stream |<br>
                    self<br>
                        do: [ :each | each putOn: stream ]<br>
                        separatedBy: [ delimiter putOn: stream ] ] ]<br>
<br>
with first replaced by anyOne in Collection?<br>
</blockquote>
<br></div></div>
This assumes that the receiver is a collection of objects whose species is Array or a subclass of String (#streamContents: doesn&#39;t work with other collections IIRC). If that&#39;s the case, then there&#39;s no need to use #putOn:, because #nextPutAll: does the same and it&#39;s faster too.<br>

<br>
With my version, this:<br>
#(1 2 3) join: $- returns this:<br>
&#39;1-2-3&#39;.<br></blockquote><div><br></div><div>got it. finally.  sorry :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888">
<br>
<br>
Levente</font><div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Pharo&#39;s implementation dispatches on the class of the delimiter. That&#39;s<br>
fine, but requires multiple methods. Also I&#39;ve never used #join: to create<br>
anything else but Strings.<br>
<br>
<br>
Levente<br>
<br>
snip<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br>