Logical operations: Difference between revisions
Content deleted Content added
Line 1,986:
=={{header|Kotlin}}==
Similar style to FreeBASIC entry:
<syntaxhighlight lang="
fun logicalDemo(b1: Boolean, b2: Boolean) {
println("b1
println("b2
println("
println("b1
println("b1
println("
println("not b1
println("
println("b1 && b2 = ${b1 && b2}")
println("b1 || b2 = ${b1 || b2}")
println()
}
fun main(
logicalDemo(true, true)
logicalDemo(true, false)
logicalDemo(false, true)▼
logicalDemo(false, false)
▲ logicalDemo(false, true)
}</syntaxhighlight>
{{out}}
<pre>
b1
b2
non-short-circuiting operators:
b1 and b2 = true▼
b1
b1
not b1 = false
b1 && b2 = true▼
short-circuiting operators:
b1 || b2 = true▼
b1
b2
non-short-circuiting operators:
b1 and b2 = false▼
b1
b1
not b1
short-circuiting operators:
b1 || b2 = true▼
b1
b2
non-short-circuiting operators:
b1 and b2 = false▼
b1
b1
not b1 = true
b1 && b2 = false▼
short-circuiting operators:
b1 || b2 = false▼
b1
b2
non-short-circuiting operators:
b1
b1
not b1 = true
short-circuiting operators:
</pre>
|