To me stringOfFileReference is a bad smell.


On Fri, Dec 1, 2017 at 12:04 PM, Cyril Ferlicot
<[email protected]> wrote:
> On Fri, Dec 1, 2017 at 11:55 AM, Alistair Grant <[email protected]> wrote:
>> Hi Cyril,
>>
>> The normal way to handle this is #asFileReference, so you can just have:
>>
>> aStringOrReference asFileReference readStreamDo: ...
>>
>
> In that case, if it is a String like 'test', we will get a readStream
> on the file './test' and not on the string 'test'. This is not what I
> want.
>
> What I want is this for example:
>
>
>
> MyClass>>addComaAtTheEndOf: aStringOrFileReference
>   "If the argument is a String, add a coma at the end. If the
> parameter is a file, add a coma at the end of its contents"
>
>   aStringOrFileReference writeStreamDo: [ :s | s atEnd; nextPut: $, ]
>
>
>
> If I use your code, it will not add a coma at the end of the string
> parameter, but at the end of the file represented by the string if it
> exists.
>
>> Cheers,
>> Alistair
>>
>
>
>
> --
> Cyril Ferlicot
> https://ferlicot.fr
>
> http://www.synectique.eu
> 2 rue Jacques Prévert 01,
> 59650 Villeneuve d'ascq France
>

Reply via email to