Introduction
Operator precedence tells the computer which math or logic steps to do first when there are many in one line.
val result = 3 + 4 * 2 val check = true || false && false
val result = 3 + 4 * 2
val result = (3 + 4) * 2
val check = true || false && false
val check = (true || false) && false
fun main() { val a = 5 + 3 * 2 val b = (5 + 3) * 2 val c = true || false && false val d = (true || false) && false println("a = $a") println("b = $b") println("c = $c") println("d = $d") }
3 + 4 * 2?3 + 4 * 2 so that addition happens first?val result = 10 - 4 + 2 * 3 println(result)
val x = 5 + 3 * 2 && true
val result = true || false && false || true && false
result considering operator precedence?Pass the test and this pattern moves unknown