- 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).
推薦閱讀
- Web程序設計及應用
- 高手是如何做產品設計的(全2冊)
- 機器學習系統:設計和實現
- JavaScript:Functional Programming for JavaScript Developers
- MATLAB應用與實驗教程
- Koa開發:入門、進階與實戰
- WordPress Plugin Development Cookbook(Second Edition)
- Python機器學習算法與實戰
- Mastering Xamarin.Forms(Second Edition)
- Go語言精進之路:從新手到高手的編程思想、方法和技巧(2)
- Python 3 數據分析與機器學習實戰
- 讓Python遇上Office:從編程入門到自動化辦公實踐
- MySQL數據庫教程(視頻指導版)
- Serverless工程實踐:從入門到進階
- Learning Dynamics NAV Patterns