Bert Freudenberg wrote: >> Do I need to worry about closing a WriteStream? Currently I am >> working >> like this: >> >> buildStatementFor: anObject >> | statement | >> statement := String new writeStream. >> [ >> statement nextPutAll: 'bla bla bla'. >> ^ statement contents. >> ] ensure: statement close >> > >Not for an in-memory write stream no. > >Note you're missing the block brackets around [statement close]. > >Also, since this is such a common task, the shorter version is > >buildStatementFor: anObject > > ^String streamContents: [:statement | statement nextPutAll: 'bla bla >bla'] > >Take a look at #streamContents: which does exactly the same as your >code, but you can never get it wrong again ;)
Hi Bert, Thanks. Actually that was (of course!) just an off-the-cuff pseudocode I posted and not a copy-and-paste. My email client does not have a syntax checker, unfortunately :) #streamContents: indeed seems to be what I need. - TimJ _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners