in reply to Re^5: Variable assignment error checking
in thread Variable assignment error checking
It is not! In this expression:
$var = func($var) || $var;
the return value of func($var) will be assigned to $var if func($var) is true, otherwise the value of $var. In this expression
$var ||= func( $var );
the return value of func($var) will be assigned to $var if $var is false.
Completely different logic!
The expression $var ||= func( $var ); is shorthand for $var = $var || func( $var );. Can you spot the difference?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Variable assignment error checking
by Anonymous Monk on Dec 15, 2013 at 10:36 UTC | |
by hdb (Monsignor) on Dec 15, 2013 at 10:41 UTC |