Can someone please tell me why this compiles? And yes, I know
if
is an expression. This is a minimal example of the code.
Copy code
import java.math.BigDecimal
fun test(a: Int): BigDecimal {
val local: BigDecimal
if (a == 1) {
local = "12.0".toBigDecimal()
} else {
local = "13.0".toBigDecimal()
}
return local
}
test(1)
test(2)