[squeak-dev] [Idiom] 'myfile.txt' asFileName readStream contents

K. K. Subramaniam kksubbu.ml at gmail.com
Sun Oct 31 05:53:36 UTC 2010


On Saturday 30 Oct 2010 4:20:46 pm Hannes Hirzel wrote:
> Hello
> 
> Randal Schwartz writes in his blog
> http://methodsandmessages.posterous.com/writestreams-of-consciousness-going
> -to-xtream about streams citing Derek Williams  
> http://derekwilliams.us/?p=1411
> 
> He gives the following as an example of elegant syntax of Smalltalk
> 
>     'myfile.txt' asFileName readStream contents
> 
> This does not work in Squeak nor in Pharo.
> 
> It produces a ReadStream on the contents of the _String_  'myfile.txt'.
> i.e. the ByteString with 10 elements.
Looks like a typo. I suppose what was meant was:
   'myfile.txt' asFileName asFileStream contents

where asFileStream is a monkey patch on String:

String>>asFileStream
	^FileStream readOnlyFileNamed: self.

Subbu



More information about the Squeak-dev mailing list