printf
ErrorsCollection

printf

Synthesised documentation from type/independent-routines type/IO/Handle type/Cool type/IO/CatHandle

From type/independent-routines

See Original text in context

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

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 Junctions, it will also autothread, without a guaranteed order.

printf"%.2f ", ⅓ | ¼ | ¾ ); # OUTPUT: «0.33 0.25 0.75 »

From type/IO/Handle

See Original text in context

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 sprintf for details on acceptable format directives.

Attempting to call this method when the handle is :$enc 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;

From type/Cool

See Original text in context

method printf(*@args)

Uses the object, as long as it is a format directives, to format and print the arguments

"%.8f".printf(now - now ); # OUTPUT: «-0.00004118» 

From type/IO/CatHandle

See Original text in context

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!