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

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.

主站蜘蛛池模板: 文山县| 平度市| 永春县| 灵川县| 社旗县| 宁阳县| 佳木斯市| 霸州市| 都兰县| 大姚县| 通山县| 新巴尔虎左旗| 株洲县| 乐陵市| 方正县| 乌鲁木齐市| 河池市| 海安县| 南安市| 卓资县| 崇信县| 永福县| 吐鲁番市| 延津县| 长春市| 得荣县| 张家川| 桓台县| 柳州市| 景东| 吉林省| 巴彦县| 宿松县| 衡南县| 大同县| 奈曼旗| 巨鹿县| 铜山县| 闸北区| 广丰县| 三原县|