Search code examples
smalltalkvisualworksgnu-smalltalk

Smalltalk usage of printFormat: method


Can someone please give me an example of how to use the printFormat: method in Smalltalk to format a string?

Eg:

'123456789' printFormat: aFormat should return something like $123,456,789.00


Solution

  • The normal way to find examples of the usage of a method in smalltalk is to select it and then search for senders. Most smalltalks (VW, Squeak, Pharo, Dolphin, Amber etc) have a keyboard shortcut for that.

    If the number is too large, you might want to take a look at implementors.

    Smalltalk often has little help text and comments, but a lot of real code using a specific construct.

    We try to avoid using floats in currency calculations. ScaledDecimals work better, and you might want to create a real Money class