Since using a stream to construct a collection is a very common task,
there is a nice helper construct for this:
String streamContents: [:stream |
1 to: 10000 do: [:i | stream print: i]]
This spares you to declare one temporary variable and is overall more
readable.
Also, I used the stream's #print: method which will append a string
representation of its argument - you could, of course, use #nextPutAll:,
too.
Btw, do *not* put parens around "1 to: 10000". Of course this works, but
writing "1 to: 10000 do:" uses the #to:do: message which is way more
efficient, and a tiny bit shorter to read, too.
Thank you for all this advices. It will help.
--
Damien Cassou
_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners