官术网_书友最值得收藏!

The Boolean type

Boolean is a logic type that has two possible values: true and false. We can also use the nullable Boolean type:

    val isGrowing: Boolean = true 
    val isGrowing: Boolean? = null 

The Boolean type also supports standard built-in operations that are generally available in most modern programming languages:

  • ||: Logical OR. Returns true when any of two predicates return true.
  • &&: Logical AND. Returns true when both predicates return true.
  • !: Negation operator. Returns true for false, and false for true.

Keep in mind that we can only use a not-null Boolean for any type of condition.

Like in Java, in || and && predicates are evaluated lazily, and only when needed (lazy conjunction).

主站蜘蛛池模板: 巴东县| 英山县| 天门市| 新绛县| 娄烦县| 江达县| 化州市| 鄂州市| 永安市| 高邑县| 旬邑县| 报价| 成都市| 洞头县| 个旧市| 鄂州市| 永善县| 安庆市| 天峻县| 双鸭山市| 江孜县| 湖州市| 剑河县| 泗洪县| 邵阳市| 日土县| 长岭县| 武城县| 衡南县| 全州县| 榆中县| 化隆| 五莲县| 新乡市| 泰顺县| 长治县| 台湾省| 凤庆县| 闽侯县| 洞头县| 乌苏市|