[Newbies] using collect on a ReadStream

Oscar Nierstrasz oscar.nierstrasz at gmail.com
Tue Oct 30 07:03:13 UTC 2007


Hi Norbert,

Streams don't support the collection protocols.  You can convert a  
stream to a collection by sending #contents to the stream:

stream := (ReadStream on: #( #(#a #b) #(#b #c))).
stream contents collect: [:each| 'k',each first] --> #('ka' 'kb')

Is that what you want?

Cheers, Oscar

On Oct 30, 2007, at 2:00, Norbert Hartl wrote:

> Hi,
>
> I get a ReadStream from some part of a program which is
> created this way
>
> stream := (ReadStream on: #( #(#a #b) #(#b #c)))
>
> I like to use collect: on that stream:
>
> stream collect: [:each| 'k',each first]
>
> Is there a possibility to specify the resulting collection
> produced by collect. The problem here is the species
> call with an add: call afterwards which is not appropriate
> (the debugger said :) )
>
> thanks,
>
> Norbert
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



More information about the Beginners mailing list