Go 逻辑运算符


逻辑运算符

逻辑运算符用于确定变量或值之间的逻辑:

Operator Name Description Example 尝试一下
&&  Logical and Returns true if both statements are true x < 5 &&  x < 10 尝试一下 »
||  Logical or Returns true if one of the statements is true x < 5 || x < 4 尝试一下 »
! Logical not Reverse the result, returns false if the result is true !(x < 5 && x < 10) 尝试一下 »