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

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).

主站蜘蛛池模板: 普安县| 深水埗区| 平罗县| 手机| 东港市| 吉首市| 瓮安县| 高雄市| 德江县| 大埔县| 榆中县| 布尔津县| 北川| 榆林市| 焦作市| 延寿县| 怀化市| 吐鲁番市| 灵丘县| 山阴县| 无锡市| 长葛市| 沙雅县| 长泰县| 沾化县| 克拉玛依市| 洪江市| 白河县| 桃源县| 永城市| 惠安县| 介休市| 延吉市| 肥城市| 封丘县| 栖霞市| 平舆县| 修武县| 玛纳斯县| 张家界市| 湟源县|