Hi Cyril, On 1 December 2017 at 12:04, Cyril Ferlicot <cyril.ferlicot@gmail.com> wrote:
On Fri, Dec 1, 2017 at 11:55 AM, Alistair Grant <akgrant0710@gmail.com> 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.
Sorry, I misunderstood. This looks like a good addition. Although is there any reason it shouldn't be added to SequenceableCollection, where #readStream and #writeStream are defined? Cheers, Alistair