kotlin if
snippet in kotlin

when kotlin

user1949

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

kotlin if

user6410

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

kotlin else if

user7486

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