Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
String method format:
Last updated at 6:50 am UTC on 14 August 2019
A message people used to C-style languages will find #format: useful.

This provides printf() like functionality.


Example.1

'I want {1} apples' format: #(3).
=> 'I want 3 apples'

The arguments must be supplied as a Collection, Here I supplied an array.

Example.2

Taken from the String format: method code.
'\{ \} \\ foo {1} bar {2}' format: {12. 'string'}.
=> '{ } \ foo 12 bar string'


See also
String method expandMacrosWith:
STT - Smalltalk Templates