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

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

主站蜘蛛池模板: 金秀| 平阴县| 苏尼特右旗| 宁远县| 盐池县| 互助| 延寿县| 潮州市| 罗定市| 富民县| 佛学| 方正县| 哈尔滨市| 淳安县| 长治县| 灯塔市| 通许县| 且末县| 且末县| 雷波县| 韶山市| 宁波市| 稷山县| 同德县| 丰都县| 合山市| 南溪县| 都昌县| 蛟河市| 射洪县| 丹阳市| 澄城县| 丹东市| 察隅县| 台江县| 长岛县| 台湾省| 武汉市| 容城县| 驻马店市| 淳化县|