A sealed interface restricts its implementations to a set known when the containing module is compiled. This makes a closed hierarchy explicit and enables compiler-checked handling. section 4.1.5 section 4.6
A small sealed hierarchy
sealed interface Toggleable { fun toggle() } class LightSwitch : Toggleable { override fun toggle() = println("Lights!") } class Camera : Toggleable { override fun toggle() = println("Camera!") } The interface declares the shared operation; the two classes provide the known implementations. section 4.1.5
Handling every implementation in a when expression removes the need for an else branch. Adding another implementation makes a value-returning when expression fail to compile until its case is handled. section 4.1.5
sealed interface Toggleable {
fun toggle() #1
}
class LightSwitch: Toggleable { #2
override fun toggle() = println("Lights!")
}
class Camera: Toggleable { #2
override fun toggle() = println("Camera!")
}
Browse the compact Toggleable example showing the sealed declaration, shared method, and concrete implementations. section 4.1.5

