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

Code Example 1

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

Code Example 2

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