[squeak-dev] PositionableStream >> peekBack

Jakob Reschke jakob.reschke at student.hpi.de
Wed Jun 21 13:00:28 UTC 2017


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


More information about the Squeak-dev mailing list