官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 大渡口区| 金门县| 马鞍山市| 抚州市| 海淀区| 雷山县| 金华市| 黔西县| 彰武县| 嘉黎县| 大丰市| 佛坪县| 开封市| 大新县| 宜兰市| 甘南县| 丘北县| 松桃| 抚宁县| 莒南县| 萍乡市| 巢湖市| 博罗县| 临武县| 深圳市| 沅陵县| 长治市| 塔河县| 轮台县| 吐鲁番市| 彭水| 普兰县| 泰安市| 同德县| 石泉县| 青田县| 宣化县| 马关县| 东明县| 澄江县| 临泉县|