[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] question about ByteStream(Stream)>>#next:

From: Stephen Compall
Subject: Re: [Help-smalltalk] question about ByteStream(Stream)>>#next:
Date: Wed, 25 Oct 2006 16:44:26 -0500
User-agent: Thunderbird (Macintosh/20060909)

Robin Redeker wrote:
> Hi,
> i'm currently running this expression and wonder why i got a backtrace:
>    st> ((ByteStream on: 'foobar') next: 3)!

st> ByteStream comment displayNl!
My instances are read/write streams specially crafted for ByteArrays.
They are able to write binary data to them.
st> ByteArray comment displayNl!
My instances are similar to strings in that they are both represented as
a sequence of bytes, but my individual elements are integers, where as
a String's elements are characters.

In other words, if you really must use a ByteStream, do ByteStream on:
'foobar' asByteArray.  Otherwise, see ReadWriteStream, ByteStream's
superclass, for an alternative.

> As the collection used internally in ByteStream is a String 
> (ByteStream>>#species returns that at least)
> (super next) returns a Character and not a SmallInteger.

Stream>>#species and overriders refer to the kind of collection
answered by #upTo: and other methods that "read from" or "write to"
the stream, which works as expected.  The question of the underlying
collection's class is a PositionableStream-specific concept.

Stephen Compall

reply via email to

[Prev in Thread] Current Thread [Next in Thread]