routine join

Documentation for routine join assembled from the following types:

class Thread

From Thread

(Thread) method join

method join(Thread:D)

Waits for the thread to finish.

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 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. Note that you can omit the $separator if you use the method syntax.

Example:

join '', <a b c>;             # RESULT: «a, b, c»

Note that the method form does not flatten sublists:

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

The method form also allows you to omit the separator:

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

But it behaves slurpily, flattening all arguments after the first into a single list:

say join('|'3'þ'1+4i);    # OUTPUT: «3|þ|1+4i␤» 
say join '', <a b c>'d''e' , 'f'# OUTPUT: «a, b, c, d, e, f␤»

In this case, the first 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::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␤»

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.