$cough ||= cough( $cough ); | [reply] |
The OP requested to assign the return value of func($var) if that return value is true. Otherwise, to hold the original value of $var.
You coughed up this: If $var is true, keep it, otherwise store a return value from func($var).
To put it another way: Specification: if the function returns a true value, store it. Otherwise keep the original value.
Your solution: If the original value is true keep it, otherwise call the function and keep its return value instead.
Inverted logic. But you're not alone; several people upvoted your post, so it must be an easy mistake to make.
| [reply] [d/l] [select] |
... Inverted logic. But you're not alone; several people upvoted your post, so it must be an easy mistake to make. This :) When brain function less (like sleep deprivation), pattern recognition takes place instead of logic processing ... and $foo = bar($foo) || $foo; is so close to $foo = $foo || bar($foo); the association to $foo ||= bar( $foo ); happens, and tired brain fail to realize they're different human brains, what can I tell you :)
hmm, its more like logic processing doesn't check pattern recognition ... argument validation, even for brains
| [reply] [d/l] [select] |
Call the function cough($cough) only if $cough is true?
| [reply] [d/l] [select] |