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

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 ||.

主站蜘蛛池模板: 安西县| 定结县| 洪江市| 遂川县| 安康市| 鄂州市| 沧州市| 鸡泽县| 平山县| 阳江市| 隆安县| 大姚县| 景洪市| 电白县| 罗江县| 台湾省| 朝阳县| 新闻| 安龙县| 安乡县| 库伦旗| 碌曲县| 惠东县| 萨嘎县| 玉田县| 富顺县| 江达县| 廉江市| 三亚市| 泰顺县| 启东市| 财经| 湘乡市| 石门县| 油尖旺区| 甘德县| 南平市| 海阳市| 潜江市| 呼伦贝尔市| 新乡县|