- 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).
推薦閱讀
- Delphi程序設(shè)計(jì)基礎(chǔ):教程、實(shí)驗(yàn)、習(xí)題
- Mastering Natural Language Processing with Python
- Wireshark Network Security
- The Computer Vision Workshop
- Learning Selenium Testing Tools(Third Edition)
- Java程序設(shè)計(jì):原理與范例
- Learning JavaScript Data Structures and Algorithms
- HTML5與CSS3基礎(chǔ)教程(第8版)
- C語言程序設(shè)計(jì)
- Building Machine Learning Systems with Python(Second Edition)
- Instant PHP Web Scraping
- Fastdata Processing with Spark
- Practical Microservices
- 數(shù)字媒體技術(shù)概論
- Visual Basic程序設(shè)計(jì)基礎(chǔ)