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

Chris Cunnington smalltalktelevision at gmail.com
Sun Dec 30 16:37:08 UTC 2012


On 2012-12-30 8:52 AM, Colin Putney wrote:
>
>
> On Sat, Dec 29, 2012 at 12:30 PM, Chris Cunnington 
> <smalltalktelevision at gmail.com <mailto: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
>
Martin also made it look easier with a write than a read. I think I was 
looking at it the wrong way around. The OC shouldn't be the receiver but 
the argument. #writing into a String instead of #reading an OC.

Thanks,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20121230/758ba4cd/attachment.htm


More information about the Squeak-dev mailing list