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

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

主站蜘蛛池模板: 宜阳县| 阿图什市| 清丰县| 伊金霍洛旗| 苏尼特左旗| 隆子县| 太仆寺旗| 马鞍山市| 吉首市| 孙吴县| 九龙城区| 本溪| 天全县| 黔南| 黄平县| 巴马| 新竹市| 丹巴县| 大港区| 宁强县| 专栏| 策勒县| 鄂尔多斯市| 无棣县| 沁源县| 南陵县| 济阳县| 如东县| 东乌| 高阳县| 响水县| 延庆县| 遵义市| 柳河县| 德阳市| 罗江县| 罗源县| 娄底市| 灵丘县| 当阳市| 芒康县|