Documentation for routine join assembled from the following pages:

Class: Any §

From Any

(Any) method join §

Defined as

method join($separator = ''is nodal

Converts the object to a list by calling self.list, and calls .join on the list. Can take a separator, which is an empty string by default.

(1..3).join.say;       # OUTPUT: «123␤» 
<a b c>.join("").put# OUTPUT: «a❧b❧c␤»

Class: Thread §

From Thread

(Thread) method join §

method join(Thread:D:)

Waits for the thread to finish.

Class: List §

From List

(List) routine join §

Defined as:

sub    join($separator*@list)
method join(List:D: $separator = "")

Treats the elements of the list as strings by calling .Str on each of them, interleaves them with $separator and concatenates everything into a single string.

Example:

say join '', <a b c>;             # OUTPUT: «a, b, c␤»

The method form also allows you to omit the separator:

say <a b c>.join;               # OUTPUT: «abc␤»

Note that the method form does not flatten sublists:

say (1, <a b c>).join('|');     # OUTPUT: «1|a b c␤»

The subroutine form behaves slurpily, flattening all arguments after the first into a single list:

say join '|'1, <a b c>;       # OUTPUT: «1|a|b|c␤»

In this case, the list <a b c> is slurped and flattened, unlike what happens when join is invoked as a method.

If one of the elements of the list happens to be a Junction, then join will also return a Junction with concatenation done as much as possible:

say ("a"|"b","c","d").join;     # OUTPUT: «any(acd,bcd)␤»

Class: IO::Spec::Cygwin §

From IO::Spec::Cygwin

(IO::Spec::Cygwin) method join §

Defined as:

method join(|c)

Same as IO::Spec::Win32.join, except replaces backslashes with slashes in the final result.

Class: IO::Spec::Unix §

From IO::Spec::Unix

(IO::Spec::Unix) method join §

Defined as:

method join ($Str:D $dirStr:D $file --> Str:D)

Similar to catpath, takes two path fragments and concatenates them, adding or removing a path separator, if necessary, except it will return just $file if both $dir and $file are string '/' or if $dir is the string '.'. The first argument is ignored (it exists to maintain consistent interface with other IO::Spec types for systems that have volumes).

IO::Spec::Unix.join($'foo''bar').say# OUTPUT: «foo/bar␤» 
IO::Spec::Unix.join($'/''/').say;     # OUTPUT: «/␤» 
IO::Spec::Unix.join($'.''foo').say;   # OUTPUT: «foo␤» 
say $*SPEC.join(True,".","/foo");         # OUTPUT: «/foo␤»

Class: IO::Spec::Win32 §

From IO::Spec::Win32

(IO::Spec::Win32) method join §

Defined as:

method join (Str:D $volumeStr:D $dirStr:D $file --> Str:D)

Similar to catpath, takes two path fragments and concatenates them, adding or removing a path separator, if necessary, except it will return just $file if both $dir and $file are string '/' or if $dir is the string '.'. The first argument is ignored (it exists to maintain consistent interface with other IO::Spec types for systems that have volumes).

IO::Spec::Win32.join('C:''/some/dir''foo.txt').say;
# OUTPUT: «C:/some/dir\and/more␤» 
 
IO::Spec::Win32.join('C:''.''foo.txt').say;
# OUTPUT: «C:foo.txt␤» 
 
IO::Spec::Win32.join('C:'\'/').say;
# OUTPUT: «C:\␤» 
 
IO::Spec::Win32.join('//server/share'\'/').say;
# OUTPUT: «//server/share␤» 
 
IO::Spec::Win32.join('E:''''foo.txt').say;
# OUTPUT: «E:foo.txt␤»