```The bitwise operations and, or, and xor are fam...
# announcements
s
Copy code
The 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 ?
j
Copy code
fun foo() = false
fun boo() = { print("boo!"); true }
print("a = ")
foo() && boo()
print("\nb = ")
foo() and boo()
result:
Copy code
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