Check out example codes for "when kotlin". It will help you in understanding the concepts better.

Code Example 1

val x = 3
when(x) {
    3 -> println("yes")
    8 -> println("no")
    else -> println("maybe")
}
// when can also be used as an expression!
val y = when(x) {
    3 -> "yes"
    8 -> "no"
    else -> "maybe"
}
println(y) // "yes"

Code Example 2

if (a > b) {
    max = a
} else {
    max = b
}

Code Example 3

when (x) {
    1 -> print("x == 1")
    2 -> print("x == 2")
    else -> { // Note the block
        print("x is neither 1 nor 2")
    }
}

Learn ReactJs, React Native from akashmittal.com