method printf

Documentation for method printf assembled from the following types:

class Cool

From Cool

(Cool) 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::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;

class IO::CatHandle

From IO::CatHandle

(IO::CatHandle) method printf

Defined as:

multi method printf(|)

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