In Cool§
See primary documentation in context for method printf
method printf(*)
Uses the object, as long as it is a format string, to format and print the arguments
"%.8f".printf(now - now ); # OUTPUT: «-0.00004118»
In Independent routines§
See primary documentation in context for routine printf
multi printf(Cool , *)
Produces output according to a format. The format used is the invocant (if called in method form) or the first argument (if called as a routine). The rest of the arguments will be substituted in the format following the format conventions. See sprintf for details on acceptable format directives.
"%s is %s".printf("þor", "mighty"); # OUTPUT: «þor is mighty»printf( "%s is %s", "þor", "mighty"); # OUTPUT: «þor is mighty»
On Junction
s, it will also autothread, without a guaranteed order.
printf( "%.2f ", ⅓ | ¼ | ¾ ); # OUTPUT: «0.33 0.25 0.75 »
In IO::Handle§
See primary documentation in context for method printf
multi method printf(IO::Handle: Cool , *)
Formats a string based on the given format and arguments and .print
s the result into the filehandle. See sprintf for details on acceptable format directives.
Attempting to call this method when the handle is in binary mode will result in X::IO::BinaryMode
exception being thrown.
my = open 'path/to/file', :w;.printf: "The value is %d\n", 32;.close;