fun main() {
val d: Int // 1
if (someCondition()) {
d = 1 // 2
} else {
d = 2 // 2
}
println(d) // 3
}
輸出畫面
1
- Declares a variable without initialization.
- Initializes the variable with different values depending on some condition.
- Reading the variable is possible because it's already been initialized.
沒有留言:
張貼留言