diff options
author | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-11-15 11:47:53 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-11-15 11:47:53 +0100 |
commit | bdc7923bddf5c9272e5e4e7e5618229a2b598165 (patch) | |
tree | 0464b62b4282be3e809e6072a797f3dad5ee371d /pod/perlop.pod | |
parent | aca83993e8f7992e6cffa683d01dd8bb4c5440f2 (diff) | |
download | perl-bdc7923bddf5c9272e5e4e7e5618229a2b598165.tar.gz |
Doc fix for [perl #78642] Logical defined or not equivalent to ternary operator with defined
The ternary operator can be used in lvalue context; $a // $b cannot.
Diffstat (limited to 'pod/perlop.pod')
-rw-r--r-- | pod/perlop.pod | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod index 5dd86eb125..aaa86de04a 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -510,10 +510,11 @@ Although it has no direct equivalent in C, Perl's C<//> operator is related to its C-style or. In fact, it's exactly the same as C<||>, except that it tests the left hand side's definedness instead of its truth. Thus, C<$a // $b> is similar to C<defined($a) || $b> (except that it returns the value of C<$a> -rather than the value of C<defined($a)>) and is exactly equivalent to -C<defined($a) ? $a : $b>. This is very useful for providing default values -for variables. If you actually want to test if at least one of C<$a> and -C<$b> is defined, use C<defined($a // $b)>. +rather than the value of C<defined($a)>) and yields the same result than +C<defined($a) ? $a : $b> (except that the ternary-operator form can be +used as a lvalue, while C<$a // $b> cannot). This is very useful for +providing default values for variables. If you actually want to test if +at least one of C<$a> and C<$b> is defined, use C<defined($a // $b)>. The C<||>, C<//> and C<&&> operators return the last value evaluated (unlike C's C<||> and C<&&>, which return 0 or 1). Thus, a reasonably |