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

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

主站蜘蛛池模板: 历史| 民勤县| 孟州市| 得荣县| 江门市| 玉环县| 黑龙江省| 乌兰浩特市| 霍山县| 河北区| 麻江县| 辽阳市| 龙山县| 张家川| 宝丰县| 克拉玛依市| 大邑县| 额尔古纳市| 城固县| 武夷山市| 渭南市| 沙田区| 宁晋县| 洛南县| 于都县| 望城县| 渭源县| 新竹市| 伊金霍洛旗| 祁阳县| 扶风县| 凯里市| 桑日县| 大厂| 柏乡县| 汽车| 保山市| 马尔康县| 深泽县| 泸州市| 大田县|