Skip to content

Commit

Permalink
Documents junction.new refs #2703
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Apr 1, 2019
1 parent 96546a4 commit b95e6b0
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions doc/Type/Junction.pod6
Expand Up @@ -34,7 +34,7 @@ L<C<.all>|/routine/all>, L<C<.none>|/routine/none> or L<C<.one>|/routine/one> on
the object.
say so 3 == (1..30).one; # OUTPUT: «True␤»
say so ("a" ^ "b" ^ "c") eq "a"; # OUTPUT: «True␤»
say so ("a" ^ "b" ^ "c") eq "a"; # OUTPUT: «True␤»
Autothreading happens when a junction is bound to a parameter of a code object
that doesn't accept values of type C<Junction>. Instead of producing an error,
Expand Down Expand Up @@ -196,6 +196,22 @@ this case on a Junction) and the result will be a C<Bool>.
=head1 Methods
=head2 method new
Defined as:
multi method new(Junction: \values, Str :$type!)
multi method new(Junction: Str:D \type, \values)
Constructor to define a new Junction from the type that defines de Junction and
a set of values.
my $j = Junction.new(<Þor Oðinn Loki>, type => "all");
my $n = Junction.new( "one", 1..6 )
=head2 method Str
Defined as:
Expand Down Expand Up @@ -237,9 +253,9 @@ Defined as:
multi sub infix:<~>(Junction:D $a, Str:D $b)
multi sub infix:<~>(Junction:D \a, Junction:D \b)
The infix C<~> concatenation can be used to merge junctions into a single one or merge Junctions with strings.
The resulting junction will have all elements merged as if they were
joined into a nested loop:
The infix C<~> concatenation can be used to merge junctions into a single one or
merge Junctions with strings. The resulting junction will have all elements
merged as if they were joined into a nested loop:
=begin code
my $odd = 1|3|5;
Expand All @@ -256,7 +272,9 @@ my $postfixed = $odd ~ "1";
say "Found 11" if 11 == $postfixed; #OUTPUT: «Found 11!␤»
=end code
On the other hand, the versions of C<~> that use a string as one argument will just concatenate the string to every member of the Junction, creating another Junction with the same number of elements.
On the other hand, the versions of C<~> that use a string as one argument will
just concatenate the string to every member of the Junction, creating another
Junction with the same number of elements.
=head1 See Also
Expand Down

0 comments on commit b95e6b0

Please sign in to comment.