First page Back Continue Last page Overview Graphics

String Formatting

% is the remainder operator for integer numbers, but in string context it is overloaded to work on strings.

The % operator provides a simple way to format values as strings, according to a format definition string. (similar to C's sprintf function)

The way it works:

1. A format string is positioned on the left of the % operator with embedded conversion targets starting with a % (e.g., "%5d").

2. On the right side of the % operator is a tuple of values, each corresponding to the conversion targets on the left side.