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

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

主站蜘蛛池模板: 庆元县| 临澧县| 岳阳县| 和田县| 溧阳市| 福建省| 蕉岭县| 监利县| 中山市| 桃江县| 沁阳市| 西峡县| 商河县| 新蔡县| 修水县| 肥东县| 台中县| 钦州市| 珲春市| 南漳县| 锡林郭勒盟| 汪清县| 宁安市| 尼木县| 新乡县| 常熟市| 昆明市| 黑龙江省| 盐津县| 宁波市| 廉江市| 特克斯县| 德阳市| 高州市| 麻江县| 乐都县| 汾阳市| 广水市| 马尔康县| 阿拉善左旗| 汝城县|