Home Segments Index Top Previous Next

492: Mainline

Once you have defined formatWithWidth: for strings, you can define formatWithWidth: for numbers. All you need to do is to convert the number to a string, using asString, and then to activate the formatWithWidth: method:

Number method definition • instance 
formatWithWidth: w 
  ^ self asString formatWithWidth: w