Skip to content

Commit 9de42a4

Browse files
committed
Borrow parts of the description of ^^ from the synopsis to describe how it really behaves when all the arguments are false.
1 parent e01fd79 commit 9de42a4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

doc/Language/operators.pod6

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,11 +1723,16 @@ true value, the arguments to the right of are never evaluated.
17231723
17241724
=head2 infix C«^^»
17251725
1726-
Returns the first true argument if there is only one, and L<Nil> otherwise.
1727-
Short-circuits as soon as two true arguments are found.
1726+
X<Short-circuit exclusive-or>. Returns the true argument if there
1727+
is one (and only one). Returns the last argument if all arguments are false.
1728+
Returns C<Nil> otherwise (when more than one argument is true).
1729+
1730+
This operator short-circuits in the sense that it does not evaluate
1731+
any arguments after a 2nd true result.
17281732
17291733
say 0 ^^ 42; # 42
1730-
say 0 ^^ 42 ^^ 1 ^^ die 8; # (empty line)
1734+
say '' ^^ 0; # 0
1735+
say 0 ^^ 42 ^^ 1 ^^ die "never called"; # (empty line)
17311736
17321737
Note that the semantics of this operator may not be what you assume: infix C«^^»
17331738
flips to first true value it finds, and then flips to Nil I<forever> after the

0 commit comments

Comments
 (0)