Skip to content

Instantly share code, notes, and snippets.

@hrules6872
Created June 29, 2018 20:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hrules6872/b69c89d5b070eb0eb2ecc809f921bd54 to your computer and use it in GitHub Desktop.
Save hrules6872/b69c89d5b070eb0eb2ecc809f921bd54 to your computer and use it in GitHub Desktop.
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