[Newbies] appending Strings

Randal L. Schwartz merlyn at stonehenge.com
Fri Oct 3 15:17:37 UTC 2008

>>>>> "Mark" == Mark Volkmann <mark at ociweb.com> writes:

Mark> stream := WriteStream on: ''.
Mark> stream nextPutAll: 'foo'.
Mark> stream nextPutAll: 'bar'.
Mark> s := stream contents

s := String streamContents: [:stream |
        nextPutAll: 'foo';
        nextPutAll: 'bar'.

Then you don't even have to name the stream, because it has that
temporary name inside the block.

Look for the many senders of #streamContents: as examples.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

More information about the Beginners mailing list