join
Keith Hodges
keith_hodges at yahoo.co.uk
Thu Sep 14 23:57:52 UTC 2006
Entirely against my will, I once worked in a perl shop, and I noticed
that perlites liked joining things.
Whenever I find myself wanting to join a bunch of items together (e.g.
to make a path) I am never satisfied with the result and so I took a
look at the Collections/String classes to see whether anything fitted
nicely.
I came up with
SequencableCollection>>join: aCollection
^ self class streamContents: [ :stream |
aCollection
do: [ :each | stream nextPut: each ]
separatedBy: [ stream nextPutAll: self ] ]
and
Character>>join: aCollectionOfStrings
^ self class streamContents: [ :stream |
aCollectionOfStrings
do: [ :each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: self ] ]
and
Collection>>joinWith: aCollection
aCollection join: self
----
This now allows
(Array with: 1 with: 2) join: (Array with: 3 with: 4 with: 5)
$/ join: (Array with: 'Hello' with: 'my' with: 'World').
any thoughts? I am curious as to why #join: hasn't made it into the core
image, and if it were to how would it happen?
Keith
___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
More information about the Squeak-dev
mailing list
|