Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document IO::Handle.printf
Remove paragraph about workarounds
  • Loading branch information
zoffixznet committed Nov 27, 2016
1 parent 08b6467 commit 96ffea2
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions doc/Type/IO/Handle.pod6
Expand Up @@ -201,32 +201,18 @@ $fh.close;
=head2 method printf
This method is mostly identical to the C library C<printf> and
sprintf functions. The only difference between the two functions is
that C<sprintf> returns a string while the C<printf> function writes
to a file. See L<sub sprintf|https://docs.perl6.org/type/Str#sub_sprintf> for details about
the Perl 6 C<$format> implementation
method printf(IO::Handle:D: Cool $format, *@args)
Note that currently C<printf> is not a method for C<IO::Handle>, but
its effect may be duplicated with a work-around using C<sub sprintf>
and methods C<print> or C<say>. For example:
Formats a string based on the given format and arguments and C<.print>s the
result into the filehandle.
See L<sub sprintf|https://docs.perl6.org/type/Str#sub_sprintf> for details
on acceptable format directives.
=for code :skip-test
my $fh = open 'path/to/file', :w;
$fh.print(sprintf("%d\n", 32));
$fh.printf: "The value is %d\n", 32;
$fh.close;
The C<say> method (see below) may be used for an automatic ending
newline:
=for code :skip-test
my $fh = open 'path/to/file', :w;
$fh.say(sprintf("%d", 32));
$fh.close;
See L<sub sprintf|https://docs.perl6.org/type/Str#sub_sprintf>
for details about formatting and more examples.
=head2 method say
method say(IO::Handle:D: |)
Expand Down

0 comments on commit 96ffea2

Please sign in to comment.