Io/RightJustify

edit
revisions

what's new
search
help

kiwi


Here is a little method you can add to Sequence to allow you to right justify a field in textual output (similar to the printf %9s width specifier):

Sequence pad := method(w, s:=self; while(s size < w, s=" ".. s); s )

Io> writeln("Answer is:", 9 asString pad(4), "!")
==> Answer is:   9!
last modified on November 14, 2005, at 09:39 PM

© type-z.org and its contributing authors, 2001-2004.
Content is licensed under a Creative Commons License.