Skip to content

Commit 54be012

Browse files
Grinnzkhwilliamson
authored andcommitted
perlsub: mention when //= and ||= in signatures were added
1 parent 0a14b9f commit 54be012

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pod/perlsub.pod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,19 +401,19 @@ one parameter vary according to the earlier parameters. For example,
401401
print "$first_name $surname is known as \"$nickname\"";
402402
}
403403

404-
A default value expression can also be written using the C<//=> operator,
405-
where it will be evaluated and used if the caller omitted a value or the
406-
value provided was C<undef>.
404+
Since Perl 5.38, a default value expression can also be written using the
405+
C<//=> operator, where it will be evaluated and used if the caller omitted
406+
a value or the value provided was C<undef>.
407407

408408
sub foo ($name //= "world") {
409409
print "Hello, $name";
410410
}
411411

412412
foo(undef); # will print "Hello, world"
413413

414-
Similarly, the C<||=> operator can be used to provide a default
415-
expression to be used whenever the caller provided a false value (and
416-
remember that a missing or C<undef> value are also false).
414+
Similarly since Perl 5.38, the C<||=> operator can be used to provide a
415+
default expression to be used whenever the caller provided a false value
416+
(and remember that a missing or C<undef> value are also false).
417417

418418
sub foo ($x ||= 10) {
419419
return 5 + $x;

0 commit comments

Comments
 (0)