specially when either condition is either expensive, or has side-effects.if ((COND1 || COND2) && !(COND1 && COND2))
A while ago, I was writing a small script that recursively compared directories (and no, plain diff didn't do, although the script called diff repeatedly). Since I was interested in the similarities instead of the differences, at one moment I wrote:
next if -d $dir1 xor -d $dir2
If either of the arguments wasn't a directory, but the other was, they couldn't match. But if both were, or both weren't, furthermore analysis was necessary.
And yes, I know, xor can be written using other primitives as well. But that's not an argument, unless you also think 'for', 'while' and other looping constructs are redundant, because we have 'goto'.
Abigail
In reply to Re: Anyone use "xor" in conditionals?
by Abigail-II
in thread Anyone use "xor" in conditionals?
by bsb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |