set and stream
Michael van der Gulik
squeakml at gulik.co.nz
Sat Jul 30 00:08:30 UTC 2005
Houssam Fakih wrote:
> Hello,
>
>
>
> I’m trying to concatenate many collections (sets) together. I learn
> (from beck’s book) that the use of stream is efficient so I try the
> following code
>
>
>
> write _ WriteStream on: Set new.
>
> write nextPutAll: (Set with:4 with:5)
>
> write contents
>
>
>
> but it doesn’t work because Set isn’t a member of a
> SequenceableCollection then it doesn’t understand the message :
> replaceFrom:to:with:startingAt:
>
>
>
> Finally I try a code as:
>
> write _ WriteStream on: {}.
>
> write nextPutAll: (Set with:4 with:5)
>
> write contents asSet
>
>
>
> I’m happy with the result but I need just to know if there is another
> pattern to use Set and Stream.
I'm not entirely sure what you're trying to do, but:
a := Set with: 1 with: 'a' with: #hello.
b := Set with: 2 with: 'b' with: #world.
c := Set new.
c addAll: a.
c addAll: b.
Is that what you want? Remember to look at the Set class and see what it
can do.
Mikevdg.
More information about the Squeak-dev
mailing list
|