- Learning Scala Programming
- Vikash Sharma
- 126字
- 2021-06-30 19:07:52
Logical operators
Logical operators include ! (NOT), && (AND), and || (OR), and obviously we use these to perform logical operations on operands. These methods are written for Boolean, so they expect Boolean operands:
scala> val log_not = !true
log_not: Boolean = false
scala> val log_or = true || false
log_or: Boolean = true
scala> val log_and = true && true
log_and: Boolean = true
Logical AND and OR are short-circuiting operators. It means that these are only evaluated till the result is undetermined. This is achievable in Scala even though operators are methods, because of a feature of function calls named by-name parameters. It allows us to pass parameters by name that get evaluated later on when required at the time of method call.
推薦閱讀
- OpenStack Cloud Computing Cookbook(Third Edition)
- 自己動手寫搜索引擎
- 小程序實戰視頻課:微信小程序開發全案精講
- Power Up Your PowToon Studio Project
- 云原生Spring實戰
- 硅谷Python工程師面試指南:數據結構、算法與系統設計
- Learning AngularJS for .NET Developers
- 快速入門與進階:Creo 4·0全實例精講
- Web Developer's Reference Guide
- Python Digital Forensics Cookbook
- Clojure for Finance
- Python深度學習(第2版)
- 程序員的英語
- PyTorch生成對抗網絡編程
- 計算機輔助設計與繪圖技術(AutoCAD 2014教程)(第三版)