[Newbies] Squeak Smalltalk- How to make to “Transcript show” print more things?

RedTigerFish chihuyu at gmail.com
Mon Nov 6 07:27:52 UTC 2017

I am using Smalltalk to type in Transcript window a 1-9 multiplication table

Here is my code:

*1 to: 9 do: [:i|
    1 to: i do: [:j|
        Transcript show: j.
        Transcript show: ' * '.
        Transcript show: i.
        Transcript show: ' = '.
        Transcript show: j * i.
        Transcript show: '  '.
    Transcript show: ' '; cr.
As can be seen, the above code, although working fine, looks far from
beautiful and concise.

I had hoped to write something like :

*Transcript show: j '*' i '=' j * i.*
Unfortunately, they are wrong. I remember C has a very nice way to handle
that issue of mine.

Like, *printf("%d * %d = %d ", j, i, j * i);*

Is there a more elegant way to make Smalltalk codes elegant in this
situation ?

Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout, 
Down below's hell.
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html

More information about the Beginners mailing list