Skip to content

Commit b72cf81

Browse files
committed
Use given instead of with in handle opening
These examples might be copy-pasted into code where ignoring failures in open might be a bad idea.
1 parent 760d034 commit b72cf81

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

doc/Type/IO/Handle.pod6

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ L«C<unlock>|/routine/unlock» to remove a lock.
207207
# will wait for the other to finish before proceeding to read/write
208208
209209
# Writer
210-
with "foo".IO.open(:w) {
210+
given "foo".IO.open(:w) {
211211
.lock;
212212
.spurt: "I ♥ Perl 6!";
213213
.close;
214214
}
215215
216216
# Reader
217-
with "foo".IO.open {
217+
given "foo".IO.open {
218218
.lock: :shared;
219219
.slurp.say; # OUTPUT: «I ♥ Perl 6!␤»
220220
.close;
@@ -384,7 +384,7 @@ L<in binary mode|/type/IO::Handle#method_encoding>.
384384
385385
=begin code :skip-test
386386
(my $file = 'foo'.IO).spurt: 'I ♥ Perl';
387-
with $file.open {
387+
given $file.open {
388388
say .read: 6; # OUTPUT: «Buf[uint8]:0x<49 20 e2 99 a5 20>␤»
389389
.close;
390390
}
@@ -403,7 +403,7 @@ C<X::IO::BinaryMode> exception being thrown.
403403
404404
=begin code :skip-test
405405
(my $file = 'foo'.IO).spurt: 'I ♥ Perl';
406-
with $file.open {
406+
given $file.open {
407407
say .readchars: 5; # OUTPUT: «I ♥ P␤»
408408
.close;
409409
}
@@ -565,7 +565,7 @@ block is left.
565565
# ... do stuff with the file
566566
}
567567
568-
with "foo/bar".IO.open(:w) {
568+
given "foo/bar".IO.open(:w) {
569569
.spurt: "I ♥ Perl 6!";
570570
.close;
571571
}
@@ -594,7 +594,7 @@ Will flush the handle, writing any of the buffered data. Returns C<True>
594594
on success; otherwise, L<fails|/routine/fail> with C<X::IO::Flush>.
595595
596596
=begin code :skip-test
597-
with "foo".IO.open: :w {
597+
given "foo".IO.open: :w {
598598
LEAVE .close;
599599
$fh.print: 'something';
600600
'foo'.IO.slurp.say; # (if the data got buffered) OUTPUT: «␤»

0 commit comments

Comments
 (0)