- Learn Kotlin Programming(Second Edition)
- Stephen Samuel Stefan Bocutiu
- 131字
- 2021-06-24 14:13:26
Booleans
Booleans are rather standard, and support the usual negation, conjunction, and disjunction operations. Conjunction and disjunction are lazily evaluated, so if the left-hand side satisfies the clause, then the right-hand side will not be evaluated. Let's look at an example of the lazy evaluation:
val x = 1 val y = 2 val z = 2
val b = x > y && x > z val c = y == z || x == z
In the preceding code, since x is not greater than y, the value of b cannot be true, therefore, the right-hand side of the && operator is not invoked. Similarly, since y is equal to z, c will be true, and there is no need to evaluate the right-hand side of ||.
推薦閱讀
- Java程序設計與開發
- Flink SQL與DataStream入門、進階與實戰
- Microsoft Azure Storage Essentials
- Windows Embedded CE 6.0程序設計實戰
- HoloLens與混合現實開發
- OpenStack Networking Essentials
- Building Serverless Web Applications
- 區塊鏈項目開發指南
- Hadoop大數據分析技術
- Learning Ionic
- Kotlin Programming By Example
- Android移動應用開發項目教程
- Monitoring Docker
- INSTANT LESS CSS Preprocessor How-to
- SAP HANA Cookbook