What gives you a view of what would be returned if you sent #back is: PositionableString (and subclasses): #last StandardFileStream (and subclasses): #peekLast * this last one is matches to #back as defined in MutliByteFileStream. #last could be used, but since it uses the internal collection instVar, it may give odd results. I don't know - haven't tried it.
-cbc
On Wed, Jun 21, 2017 at 6:00 AM, Jakob Reschke <jakob.reschke@student.hpi.de
wrote:
Hi all,
I just stumbled upon the behavior of #peekBack. I expected that it would give me a "preview" of what I would get when I send #back, but without changing the position of the Stream (like #peek does for #next). Or in other words, I expected to get the last read (or written) element.
As it turned out it answers the next-to-last element instead. There even is a test case in RWBinaryOrTextStreamTest for this behavior.
But does it make sense? I have my doubts mainly because of the inconsistency with the return value of #back.
There is also #peekLast, which does what I expected, but it is only defined for File- and WriteStream and the comment says it is intended to get the last put element, not a last read/extracted/next-ed element.
Kind regards, Jakob