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

Marcel Taeumel marcel.taeumel at hpi.de
Mon Nov 6 08:20:45 UTC 2017


Hmm...

1 to: 9 do: [:i | 1 to: i do: [:j |
  Transcript showln: ('{1} * {2} = {3}' format: {i.j.i*j}) ]].

Best,
Marcel
Am 06.11.2017 08:28:00 schrieb RedTigerFish <chihuyu at gmail.com>:
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
_______________________________________________
Beginners mailing list
Beginners at lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20171106/0d9ea126/attachment-0001.html>


More information about the Beginners mailing list