routine printf

Documentation for routine printf assembled from the following types:

language documentation Independent routines

From Independent routines

(Independent routines) routine printf

Defined as:

method printf (*@args)
multi sub printf(Cool:D $format*@args)

As a method, takes the object as a format using the same language as Str.sprintf; as a sub, its first argument will be the format string, and the rest of the arguments will be substituted in the format following the format conventions.

"%s is %s".printf("þor""mighty");    # OUTPUT: «þor is mighty» 
printf"%s is %s""þor""mighty");  # OUTPUT: «þor is mighty»

class IO::CatHandle

From IO::CatHandle

(IO::CatHandle) method printf

Defined as:

multi method printf(|)

The IO::CatHandle type overrides this method to throw a X::NYI exception. If you have a good idea for how this method should behave, tell Rakudo developers about it!

class IO::Handle

From IO::Handle

(IO::Handle) method printf

Defined as:

multi method printf(IO::Handle:D: Cool $format*@args)

Formats a string based on the given format and arguments and .prints the result into the filehandle. See sub 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 $fh = open 'path/to/file':w;
$fh.printf: "The value is %d\n"32;
$fh.close;