So if I do this:
$value ||= $default;
I can also do this:
$value &&= munge($value);
However, what's the negated // operator?
$value //= $default;
I'm sure there must be something there, but I'm missing it.
Re:And is not really the negation of or
Aristotle on 2007-11-19T11:41:39
Reminds me of this:
${parameter:+word}
Use Alternate Value. If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted.
That’s from man bash under “Parameter Expansion”. It comes in handy when you want to decide whether to pass a switch to a program based on the presence of some flag variable.
Re:And is not really the negation of or
Ovid on 2007-11-19T12:11:48
It's useful if you want to munge a value if it's defined. I've found it useful when doing something like this:
$message &&= $cgi->p($message);In other words, if there is no message, don't stick in extraneous paragraph tags in the HTML. I'm sure there are plenty of other cases where you might want to take an extra action if a value is defined.
Re:And is not really the negation of or
btilly on 2007-11-19T18:44:31
So we need a && operator to go with//? :-P Re:And is not really the negation of or
Ovid on 2007-11-19T21:35:14
Heh. Something like that
:) Now where are my Unicode cheat sheets ...