XOR of three values

前端 未结 8 947
执念已碎
执念已碎 2020-12-02 23:04

What is the simplest way to do a three-way exclusive OR?

In other words, I have three values, and I want a statement that evaluates to true IFF only one of

8条回答
  •  我在风中等你
    2020-12-02 23:29

    Another possibility:

    a ? !b && !c : b ^ c
    

    which happens to be 9 characters shorter than the accepted answer :)

提交回复
热议问题