Skip to content

Commit ef12f7f

Browse files
committed
make $x++ return 0 on appropriate undefs
Since the operator is doing something defined, the first value it returns should also be defined.
1 parent b578b58 commit ef12f7f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

S03-operators.pod

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Synopsis 3: Perl 6 Operators
1515

1616
Created: 8 Mar 2004
1717

18-
Last Modified: 23 Sep 2010
19-
Version: 220
18+
Last Modified: 10 Dec 2010
19+
Version: 221
2020

2121
=head1 Overview
2222

@@ -543,6 +543,12 @@ previously incremented. This is useful if your C<%seen> hash is
543543
actually a C<KeySet>, in which case decrement actually deletes it
544544
from the C<KeySet>.
545545

546+
Increment/decrement of an undefined C<Numeric>, C<Cool>, or C<Any> variable
547+
sets the variable to 0 and then performs the increment/decrement. Hence a
548+
postincrement returns 0 the first time:
549+
550+
my $x; say $x++; # 0, not Any
551+
546552
=over
547553

548554
=item *

0 commit comments

Comments
 (0)