- Android Development with Kotlin
- Marcin Moskala Igor Wojda
- 118字
- 2021-07-02 18:48:36
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).
推薦閱讀
- Intel Galileo Essentials
- 圖解Java數據結構與算法(微課視頻版)
- 從0到1:HTML+CSS快速上手
- Visual Basic程序設計實驗指導(第4版)
- Responsive Web Design by Example
- C# 8.0核心技術指南(原書第8版)
- Serverless computing in Azure with .NET
- Python深度學習:模型、方法與實現
- Mastering Unity 2D Game Development(Second Edition)
- 移動互聯網軟件開發實驗指導
- Getting Started with Nano Server
- 大學計算機基礎
- Learning Jakarta Struts 1.2: a concise and practical tutorial
- JavaScript Concurrency
- 量子計算機編程:從入門到實踐