Keyword for exclusive or in ruby?

后端 未结 7 1935
广开言路
广开言路 2021-01-04 00:03

Does Ruby have a plain-English keyword for exclusive or, like they have \"and\" and \"or\"? If not, is this because exclusive or doesn\'t allow evaluation short-cutting?

7条回答
  •  鱼传尺愫
    2021-01-04 00:56

    Try ^

    true  ^ false #=> true
    true  ^ true  #=> false
    false ^ false #=> false
    

    No plain english equivalent operator though.

提交回复
热议问题