C-Style Logical XOR
C-Style Logical XOR
Posted Jun 11, 2024 17:52 UTC (Tue) by NYKevin (subscriber, #129325)In reply to: C-Style Logical XOR by dskoll
Parent article: perl v5.40.0 released
I think I have occasionally wanted logical XNOR in general programming (I don't write much/any Perl), but I usually just end up writing bool(x) == bool(y) (replacing bool() with whatever the language's coerce-to-booleanish syntax looks like, or omitting it if we're in a strongly-typed language that has first-class bools). IMHO that's easier to read than a hypothetical XOR operator would be anyway. I suppose it might be useful in bash-like languages, where you'd have to screw around with $? and temporary variables to write an XOR/XNOR using equality. But no bash-like language actually has this feature (that I know of).