Search code examples
smalltalk

How to add whitespace between elements when printing them out in Smalltalk OrderedCollection?


I have created an OrderedCollection list an now I want to print it out by using the Transcript, like this:

  range do:[:each|Transcript show: each].

The output is 35791113, but I need 3 5 7 9 11 13, so I need whitespaces between elements. I tryed also just..

   Transcript show: range.

But instead of this OrderedCollection(3 5 7 9 11 13), I would like to have only list elements, without OrderedCollection. How to achieve this?


Solution

  • In Squeak, Pharo and Cuis you may do

     #(3 5 7 9 11 13) do: [:each | Transcript show: each; space]
    

    to get the result.