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

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

主站蜘蛛池模板: 盈江县| 南乐县| 乌拉特中旗| 措勤县| 长沙县| 兖州市| 巍山| 靖远县| 濮阳市| 武乡县| 西和县| 新泰市| 牟定县| 方正县| 揭西县| 象州县| 和龙市| 高台县| 延庆县| 南阳市| 吐鲁番市| 吉林市| 虞城县| 茂名市| 宜川县| 罗源县| 枝江市| 西吉县| 玉屏| 苍南县| 滕州市| 鹰潭市| 修文县| 应城市| 漳平市| 开原市| 通山县| 乌拉特中旗| 城市| 阿瓦提县| 岑溪市|