[squeak-dev] Smalltalk string API

Levente Uzonyi leves at elte.hu
Tue Feb 22 05:37:12 UTC 2011


On Mon, 21 Feb 2011, Eliot Miranda wrote:

snip

> Actually, thinking a little, why not
>
>
> Collection >> join: delimiter
>
>       ^self species streamContents: [ :stream |
>               self
>                       do: [ :each | each putOn: stream ]
>                       separatedBy: [ delimiter putOn: stream ] ]
>
> ?

Because I'd like this:
#('foo' 'bar' 'baz') join: $-
to return this:
'foo-bar-baz'
rather than this:
#($f $o $o $- $b $a $r $- $b $a $z).

Pharo's implementation dispatches on the class of the delimiter. That's 
fine, but requires multiple methods. Also I've never used #join: to create 
anything else but Strings.


Levente

snip



More information about the Squeak-dev mailing list