--- a/Stream.st Sun Nov 10 03:50:58 2019 +0100
+++ b/Stream.st Mon Nov 11 20:51:07 2019 +0100
@@ -222,6 +222,29 @@
^ self == Stream
! !
+!Stream class methodsFor:'utilities'!
+
+streamContents:blockWithArg
+ "create a write-stream instance of the receiver-class,
+ evaluate blockWithArg, passing that stream,
+ extract and return the streams contents.
+ Similar to collection>>streamContents:, but usable if
+ you don't know the type of collection in advance
+ (eg: especially for CharacterWriteStream)"
+
+ |stream|
+
+ stream := self new.
+ blockWithArg value:stream.
+ ^ stream contents
+
+ "
+ CharacterWriteStream streamContents:[:s |
+ s nextPutLine:'hello'.
+ s nextPutLine:'world'
+ ]
+ "
+! !
!Stream methodsFor:'Compatibility-Dolphin'!
@@ -250,7 +273,6 @@
self nextPut:(Character nl)
! !
-
!Stream methodsFor:'accessing'!
contents