Skip to content

Instantly share code, notes, and snippets.

@bijukunjummen
Created March 16, 2021 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bijukunjummen/e6715aca1fac9e3a7ecf321123e01c44 to your computer and use it in GitHub Desktop.
Save bijukunjummen/e6715aca1fac9e3a7ecf321123e01c44 to your computer and use it in GitHub Desktop.
sealed class Try<out T> {
    ...
    abstract fun get(): T
 
    class Success<T>(private val result: T) : Try<T>() {
        ...
        override fun get(): T = result
    }
 
    class Failure<T>(private val throwable: Throwable) : Try<T>() {
        ...
        override fun get(): T = throw throwable
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment