I suspect that is because ReadWriteStream is built to work roughly like FileStreams- except over other arbitrary collections. Basically, let's you read at arbitrary spots, go back, overwrite those spots, and then continue on. As such, I would think #contents is exactly the right behavior. Take this example:
|stream| stream := ReadWriteStream on: 'Chirs'. stream next; contents. "---< 'Chris' - the contents of the underlying collection, not some adhoc part."
What you are probably looking for is #resetToStart (which if you used in your example would not have surprised you - although the name surprised me).
-cbc
On Tue, May 1, 2018 at 1:00 PM, Chris Muller ma.chris.m@gmail.com wrote:
Does anyone know why ReadWriteStream overrides #contents from WriteStream?
WriteStream behaves as I would expect
|stream| stream := WriteStream on: String new. stream nextPutAll: 'chris'; reset; nextPutAll: 'C'; contents "---> 'C' as expected"
but ReadWriteStream doesn't...
|stream| stream := ReadWriteStream on: String new. stream nextPutAll: 'chris'; reset; nextPutAll: 'C'; contents "---> 'Chris' unexpected!"
I want to reuse a ReadWriteStream, so I want #contents to honor the end position. What's going on here?