Skip to content

Instantly share code, notes, and snippets.

@KaneCheshire
Last active September 9, 2020 17:41
Show Gist options
  • Save KaneCheshire/89610e78dda3cd0f37ade5ceb2b78290 to your computer and use it in GitHub Desktop.
Save KaneCheshire/89610e78dda3cd0f37ade5ceb2b78290 to your computer and use it in GitHub Desktop.
A re-implementation of Kotlin and Swift's Result type in Kotlin
sealed class Result<out S, out F: Throwable> {
data class Success<out S, out F: Throwable>(val value: S) : Result<S, F>()
data class Failure<out S, out F: Throwable>(val failure: F) : Result<S, F>()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment