- 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 ||.
推薦閱讀
- Boost程序庫完全開發指南:深入C++”準”標準庫(第5版)
- Visual Basic程序開發(學習筆記)
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- Visual C++實例精通
- Java高手真經(高級編程卷):Java Web高級開發技術
- Oracle 12c中文版數據庫管理、應用與開發實踐教程 (清華電腦學堂)
- SAS數據統計分析與編程實踐
- Python 3破冰人工智能:從入門到實戰
- Amazon S3 Cookbook
- 軟件架構:Python語言實現
- 大學計算機基礎實驗指導
- 0 bug:C/C++商用工程之道
- JavaScript動態網頁編程
- 自學Python:編程基礎、科學計算及數據分析(第2版)
- Learning Grunt