@@ -812,11 +812,17 @@ Defined as:
812
812
method close(IO::Handle:D: --> Bool:D)
813
813
multi sub close(IO::Handle $fh)
814
814
815
- Closes an open filehandle. It's not an error to call C < close > on an
816
- already-closed filehandle. Returns C < True > on success. If you close
817
- one of the standard filehandles (by default: C < $*IN > , C < $*OUT > , or C < $*ERR > ),
818
- that is any handle with L < native-descriptor|/routine/native-descriptor > C < 2 > or lower, you won't be
819
- able to re-open such a handle.
815
+ Closes an open filehandle, returning C < True > on success, and not erroring if the
816
+ filehandle is already closed, although if you close one of the standard
817
+ filehandles (by default: C < $*IN > , C < $*OUT > , or C < $*ERR > ), that is any handle
818
+ with L < native-descriptor|/routine/native-descriptor > C < 2 > or lower, you won't be
819
+ able to re-open them.
820
+
821
+ = for code
822
+ given "foo/bar".IO.open(:w) {
823
+ .spurt: "I ♥ Raku!";
824
+ .close;
825
+ }
820
826
821
827
It's a common idiom to use L « C < LEAVE > phaser|/language/phasers#LEAVE» for
822
828
closing the handles, which ensures the handle is closed regardless of how the
@@ -838,11 +844,6 @@ sub do-stuff-with-the-file (IO $path-to-file) {
838
844
839
845
# ... do stuff with the file
840
846
}
841
-
842
- given "foo/bar".IO.open(:w) {
843
- .spurt: "I ♥ Raku!";
844
- .close;
845
- }
846
847
= end code
847
848
848
849
B < Note: > unlike some other languages, Raku does not use reference counting,
0 commit comments