Skip to content

Commit 61cb776

Browse files
committed
[io grant] Document IO::Path.sibling
Rakudo impl: rakudo/rakudo@8bacad8f84 Tests: Raku/roast@3b36d4db0d
1 parent b9c9117 commit 61cb776

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/Type/IO/Path.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,23 @@ is dependant on the operating system. The method will L«C<fail>|/routine/fail»
473473
with C<X::IO::DoesNotExist> if the path points to a non-existent filesystem
474474
entity.
475475
476+
=head2 method sibling
477+
478+
method sibling(IO::Path:D: Str() $sibling --> IO::Path:D)
479+
480+
Allows to reference a sibling file or directory. Returns a new
481+
L«C<IO::Path>|/type/IO::Path» based on the invocant, with the
482+
# L«C<.basename>|/type/IO::Path#method_basename» changed to C<$sibling>. The
483+
C<$sibling> is allowed to be a multi-part path fragment, although
484+
# L«C<.add>|/type/IO::Path#method_add» is a better choice for such use.
485+
486+
say '.bashrc'.IO.sibling: '.bash_aliases'; # OUTPUT: «.bash_aliases".IO␤»
487+
say '/home/camelia/.bashrc'.IO.sibling: '.bash_aliases';
488+
# OUTPUT: «/home/camelia/.bash_aliases".IO␤»
489+
490+
say '/foo/' .IO.sibling: 'bar'; # OUTPUT: «/bar".IO␤»
491+
say '/foo/.'.IO.sibling: 'bar'; # OUTPUT: «/foo/bar".IO␤»
492+
476493
=head2 routine slurp
477494
478495
multi method slurp(IO::Path:D: :$bin, :$enc)

0 commit comments

Comments
 (0)