Hi Cyril,

On 1 December 2017 at 11:50, Cyril Ferlicot <[email protected]> wrote:
> Hi,
>
> I am often in the case where I have a method taking a file or a string
> as parameter and I often want to use #readStreamDo:/#writeStreamDo: in
> the method because with I do not have to care if I need to close the
> file stream or not with those. But since String do not understand
> #readStreamDo:/#writeStreamDo: I cannot do that.
>
> Maybe it's worth to implement them on String?
>
> https://pharo.fogbugz.com/f/cases/20796/String-should-understand-readStreamDo-writeStreamDo-to-be-polymorph-with-FileReference
>
> Since it add methods to String I prefer talk about it on the mailing
> list to have everyone's advice.

The normal way to handle this is #asFileReference, so you can just have:

aStringOrReference asFileReference readStreamDo: ...

Cheers,
Alistair

Reply via email to