how to use for in kotlin code example
Example 1: when kotlin
when (x) {
1 -> print("x == 1")
2 -> print("x == 2")
else -> { // Note the block
print("x is neither 1 nor 2")
}
}
Example 2: for loop kotlin
for (x in 0..10) println(x)
Example 3: kotlin if
if (a > b) {
max = a
} else {
max = b
}