https://kotlinlang.org logo
#getting-started
Title
# getting-started
k

karelpeeters

06/04/2018, 8:37 AM
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
}