views:

147

answers:

2

Hi I have an ordered collection of strings which I'm trying to display on a list widget. I do the following:

self displayWidget list: coll.

where displayWidget is a List Widget and coll is the OrderedCollection containing the strings. It will display it, but it displays it in a single line.

Instead of getting

line one
line two
line three

I get:

line oneline twoline three

I'm using visual works.*

+1  A: 

You can iterate the collection and send withCRs message to the Strings.

Here is an simple example:

| i |

i:= 0. [i < 5] whileTrue: [ Transcript show: 'Hello world.\' withCRs. i := i +1.

]

withCRs method replace each \ ocurrence for a new line and carry return.

Hope it helps you.

Koder_
+1  A: 

Inside list: you probably want something similar to

coll do: [:element | Transcript show element; cr]

When you send do: [:e | ...] to a collection it evaluates the block once for each element in the collection, each time passing the element into element.
Each time I'm sending cr to Transcript to add a carriage return after each element.

Goog