On 2012-12-29 3:46 PM, Frank Shearar wrote:
On 29 December 2012 17:30, Chris Cunnington smalltalktelevision@gmail.com wrote:
I have a question about converting an OrderedCollection full of chars into a string. [1]
I would have thought there was a method like #asString that could be sent to an OrderedCollection to produce a string. I find myself having to do the process in three steps: 1) #reading the OC; 2) creating an empty string; and then, 3) iterating over every char to put it into the String.
I think I'm missing a simpler way. Especially with Xtreams. Shouldn't I just use a filter, change the #contentSpecies, or something?
You're getting Characters, I guess, because you're reading one element at a time [1]. There's nothing stopping you reading more than that:
('abc' reading read: 3) = 'abc'. ('abc reading rest) = 'abc'.
frank
[1] It's worth bearing in mind that Xtreams operate over streams of arbitrary objects, not just characters.
I don't know. The situation is more like:
oc := #($a $b $c). oc := oc asOrderedCollection. oc reading read: 3 an OrderedCollection($a $b $c)
The terminal is the OC. But it returns an OC and I want a string from the chars. I've been looking at the transforms page of the Xtreams docs and that seems more about changing the encoding. I think my problem wasn't really about Xtreams.
Chris
Chris
[1]
startTag: data <action: 'element'> |tagdata str | tagdata := data second first reading. str := (String new: 20) writing. tagdata do: [:each| str put: each]. ^'html ' , (data first second first asString) , $: , $' , (str close; terminal) , $'