规则。布尔值
接口静态
表示布尔值true
或false
基本类型。
可以使用==
和!=
运算符来比较布尔值。
布尔值具有以下逻辑运算符:
手术 | 表达 |
---|---|
和 | x && y |
或者 | x || y |
不是 | !x |
规则评估将在布尔表达式上短路:
// Short-circuits at 'true' so someFunction() will never run true || someFunction() // Short-circuits at 'false' so someFunction() will never run false && someFunction() // someFunction() will always run false || someFunction()
可以使用bool()
函数将字符串转换为布尔值:
bool("true") == true