[Newbies] Concatenating strings stored in an ordered collection
Rob Rothwell
r.j.rothwell at gmail.com
Fri May 22 20:05:34 UTC 2009
Try output := col inject: '' into: [:a :b | a,b].
And check out the terse guide to Squeak:
http://wiki.squeak.org/squeak/5699.
I can never remember the format for inject, but got it right somehow this
time!
Rob
On Fri, May 22, 2009 at 3:51 PM, Paul DeBruicker <pdebruic at gmail.com> wrote:
> Hi
>
> I've created an ordered collection of strings. I'd like to paste each
> element of the ordered collection together into one long string that
> contains all of the elements of the ordered collection.
>
> So given this:
> | col |
> col := OrderedCollection with: 'asdf' with: '1234' with: 'aaaa'.
>
>
> I'd like to end up with this:
>
> 'asdf1234aaaa'
>
> I've come up with this:
> | col |
> col := OrderedCollection with: 'asdf' with: '1234' with: 'aaaa'.
> String streamContents: [:stream | col do: [:i | stream print: i]]
>
> but that gives:
> '''asdf''''1234''''aaaa'''
>
> What else should I do? Thanks
>
> Paul
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20090522/73a31e25/attachment.htm
More information about the Beginners
mailing list