[squeak-dev] Xtreams question - OC of chars to String

Colin Putney colin at wiresong.com
Sun Dec 30 13:52:40 UTC 2012


On Sat, Dec 29, 2012 at 12:30 PM, Chris Cunnington <
smalltalktelevision at gmail.com> wrote:

> I think I'm missing a simpler way. Especially with Xtreams. Shouldn't I
> just use a filter, change the #contentSpecies, or something?
>

Yeah, writing into an OrderedCollection with a stream is a bit suspect to
begin with. Both provide a way to grow an underlying fix-size collection as
you add more elements. If you have an OrderedCollection, you can just send
#add:, no need for a write stream. If you want to build a string, "String
new writing" will do the job, no need for an OrderedCollection.

Also, you can write an OC full of characters directly into a write stream
on a string:

chars := 'abc' asOrderedCollection.
String new writing
write: '123';
write: chars;
conclusion

Colin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20121230/59855bb1/attachment.htm


More information about the Squeak-dev mailing list