Skip to content

Commit

Permalink
Adds example for infix |, closes #1889
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Jul 8, 2018
1 parent 6664e97 commit 237e956
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions doc/Language/operators.pod6
Expand Up @@ -932,7 +932,8 @@ L<Hash> into an argument list.
slurpee( <a b c d>, { e => 3}, 'e' => 'f' => 33 )
# OUTPUT: «\(("a", "b", "c", "d"), {:e(3)}, :e(:f(33)))␤»
Please see the L<C<Signature> page, specially the section on Captures|/type/Signature#Capture_Parameters> for more information on the subject.
Please see the L<C<Signature> page, specially the section on Captures|/type/Signature#Capture_Parameters>
for more information on the subject.
Outside of argument lists, it returns a L<Slip|/type/Slip>, which makes
it flatten into the outer list. Inside L<argument
Expand Down Expand Up @@ -1295,10 +1296,17 @@ details.
multi sub infix:<|>($a, $b --> Junction:D) is assoc<list>
X<Any junction operator>.
X<|Any junction operator>
Creates an I<any> L<Junction> from its arguments.
Creates an I<any> L<Junction> from its arguments. See L<Junction> for more
details.
my $three-letters = /<[a b c]>/ | /<[i j k]>/ | /<[x y z]>/;
say $three-letters.perl; # OUTPUT: «any(/<[a b c]>/, /<[i j k]>/, /<[x y z]>/)␤»
say 'b' ~~ $three-letters; # OUTPUT: «True␤»
This first creates an C<any> C<Junction> of three regular expressions
(every one of them matching any of 3 letters), and then uses
smartmatching to check whether the letter C<b> matches any of them,
resulting in a positive match. See also L<Junction> for more details.
=head2 infix C«^»
Expand Down

0 comments on commit 237e956

Please sign in to comment.