Search code examples
quotessmalltalksqueak

How to get brackets without apostrophes from the writeStream?


I tried to get my brakets back from the wirteStream. Sadly the writeStream set two punctuation marks (apostrophes) before and after the brackets.

Could someone help me? I found the mistake for this in the class String in printOn and mainly in storeOn.

Have you an idea to solve it? I thought on RegEx... but maybe someone has another methode or solution.

| stream |
'()' printOn: (stream := '' writeStream).
stream contents = '()'.

Regards, bartak.


Solution

  • This is because String's #printOn: explicitly calls #storeOn:

    printOn: aStream 
        "Print inside string quotes, doubling inbedded quotes."
    
        self storeOn: aStream
    

    You could do it the other way around:

    (stream := '' writeStream) nextPutAll: '()'.