[squeak-dev] Printf class
Balázs Kósi
kosi.balazs at ezomer.hu
Sat Oct 6 18:29:50 UTC 2012
Hi,
I took a cursory look at the Printf package. You should send #printf:
to the format string, with the data to be formatted as the arguments.
There are some examples on the class side of FormatString. Your
example could be written as:
'%6.2e' printf: 12.343434 resulting in: ' 12.34'.
String understands #format: which is the basic string interpolation
method in Squeak, but it doesn't do any number formatting. The same
formatting as above could be achieved with methods already in the
trunk like this:
(12.343434 printShowingMaxDecimalPlaces: 2) padded: #left to: 6 with:
Character space
Maybe there is a more concise way?
HTH, Balázs
More information about the Squeak-dev
mailing list
|