in reply to Anyone use "xor" in conditionals?
On at least two occasions (but not very many more than that) I've written code like:
and those could now be rewritten:if( !$a == !$b ) { #or if( !$x != !$y ) {
but I don't adopt new Perl features lightly and I haven't written Perl code that wanted that sort of test since I noticed the existance of xor so I've never used xor, just written code where I would have used it had it been available enough at the time.if( not $a xor $b ) { #or if( $x xor $y ) {
Though, I actually find the concept of "these two logical expressions are equal" to be more useful/natural than a logical "xor" (not equal) so I'm more likely to want
than the other case and I'd probably leave that as-is rather than change it toif( !$a == !$b ) {
because I find the latter harder to understand. So I'd probably rather have an eqv (pronounced "equivalent") over an xor. (: - tyeif( not $a xor $b ) {
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Anyone use "xor" in conditionals? (yes/no)
by demerphq (Chancellor) on Jul 14, 2003 at 09:16 UTC |