逻辑运算符

名称描述
&&逻辑与 AND
!逻辑非 NOT
||逻辑或 OR
XOR逻辑异或 XOR

在 nGQL 中,非 0 数字将被视为 true 。逻辑运算符的优先级参见 Operator Precedence

  • &&

逻辑与 AND:

  1. nebula> YIELD -1 && true;
  2. ================
  3. | (-(1)&&true) |
  4. ================
  5. | true |
  6. ----------------
  • !

逻辑非 NOT:

  1. nebula> YIELD !(-1);
  2. ===========
  3. | !(-(1)) |
  4. ===========
  5. | false |
  6. -----------
  • ||

逻辑或 OR:

  1. nebula> YIELD 1 || !1;
  2. =============
  3. | (1||!(1)) |
  4. =============
  5. | true |
  • XOR

逻辑异或 XOR:

  1. nebula> YIELD (NOT 0 || 0) AND 0 XOR 1 AS ret;
  2. =========
  3. | ret |
  4. =========
  5. | true |
  6. ---------