Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Multiple numeric not or compare in if statement

by haukex (Bishop)
on Jul 02, 2020 at 07:44 UTC ( #11118795=note: print w/replies, xml ) Need Help??


in reply to Re^2: Multiple numeric not or compare in if statement
in thread Multiple numeric not or compare in if statement

if (($a == 3) || ($a == 77) || ($a == 8)) -- is equivalent to -- if (($a != 3) && ($a != 77) && ($a != 8))

No, those two aren't equivalent, they're exact opposites. It seems you didn't apply what you said:

when changing the nested logic in a condition such as that you must necessarily change the higher level logic if you wish for the original to be equivalent to the negated version.
if (($a == 3) || ($a == 77) || ($a == 8)) -- is equivalent to -- if (!( ($a != 3) && ($a != 77) && ($a != 8) ))

Replies are listed 'Best First'.
Re^4: Multiple numeric not or compare in if statement
by perlfan (Priest) on Jul 02, 2020 at 13:27 UTC
    Thanks, updated. Meant to show the exact opposite; said the opposite thing instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11118795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2020-08-10 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (58 votes). Check out past polls.

    Notices?