ShootingStar
12/17/2019, 1:01 PMThe bitwise operations and, or, and xor are familiar to most developers. The only difference between them and their logical counterparts is that they do not short-circuit. - Kotlin Cookbook
Does anyone can explain what does the short-circuit means ?Jaymin.Kim
12/18/2019, 9:44 AMfun foo() = false
fun boo() = { print("boo!"); true }
print("a = ")
foo() && boo()
print("\nb = ")
foo() and boo()
result:
a =
b = boo!
&&
is short-circuit.
this means, foo()
is false
, so boo()
don't need to call. so skipped.
and
is not short-circuit.
even foo()
is false
, boo()
will call.
This only works for Boolean