- 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.
推薦閱讀
- AngularJS Testing Cookbook
- Learning PostgreSQL
- 深入淺出Electron:原理、工程與實踐
- 信息安全技術
- Advanced Oracle PL/SQL Developer's Guide(Second Edition)
- Python Data Structures and Algorithms
- 匯編語言編程基礎:基于LoongArch
- Kivy Cookbook
- 深入理解C指針
- Django實戰:Python Web典型模塊與項目開發
- TypeScript 2.x By Example
- UX Design for Mobile
- 零基礎學Java第2版
- Java程序設計入門(第2版)
- 深度剖析ApacheDubbo核心技術內幕