June 29, 2017
2:58 p.m.
On 29 Jun 2017, at 16:07, Jérémie Regnault <jeremie.regnault@outlook.com> wrote:
Hi,
I am writing tests with streams, and I noticed that a stream opened on a string doesn't close, but FileStreams do close. Is it normal ?
How do you mean that ? That FileStreams close automatically ? That is indeed the case, that they are closed as a finalization action (i.e. when they become garbage), but that I consider that a fail safe thing, not something you should rely on. They should be properly closed, like #readStreamDo: and #writeStreamDo: do. Streams over collections such as Strings do not need closing, as there is no opening either. But general stream code better does.
-- Jérémie Regnault