Use the elvis operator, a primary constructor and ...
# getting-started
k
Use the elvis operator, a primary constructor and keep the same name:
Copy code
enum class Direction(opposite: Direction? = null) {
    NORTH, SOUTH(NORTH), EAST, WEST(EAST), START, END;
    val opposite = opposite ?: this
}