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

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

主站蜘蛛池模板: 离岛区| 石楼县| 宣武区| 尼玛县| 天水市| 平罗县| 枣强县| 长白| 兴文县| 宜春市| 乌兰察布市| 通山县| 延川县| 托克托县| 鄂托克旗| 旺苍县| 和硕县| 古丈县| 南乐县| 界首市| 辽宁省| 玛曲县| 苏尼特右旗| 平定县| 措美县| 闵行区| 合阳县| 娄底市| 灵川县| 贵阳市| 霍州市| 宁河县| 万年县| 商城县| 二手房| 全州县| 车险| 兴城市| 康乐县| 札达县| 太谷县|