Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sealed class State {
abstract val baz: Boolean
object Loading : State() {
override val baz
get() = TODO("not implemented")
override fun foo(whatever: Boolean) {
TODO("not implemented")
}
}
class Error(
val errorCode: ErrorCode,
override val baz: Boolean
) : State() {
override fun foo(whatever: Boolean) {
TODO("not implemented")
}
}
abstract fun foo(whatever: Boolean)
fun bar() = true
}
enum class ErrorCode(val errorCode: Int) {
FTW(500),
LOL(404)
}
// private val stateNotCompile = State() // Sealed types cannot be instantiated !!!
private val state = Loading // https://www.youtube.com/watch?v=Ty-IJ3qz-GE :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment