Created
July 9, 2017 18:51
-
-
Save nomisRev/ab9f3be7eb43a3876359781244ad2a6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Result { | |
fun flatMap(f: (Int) -> Result): Result = when(this) { | |
is Success -> f(value) | |
is Failure -> this | |
} | |
fun map(f: (Int) -> Int): Result = when(this) { | |
is Success -> Success(f(value)) | |
is Failure -> this | |
} | |
} | |
data class Success(val value: Int) : Result() | |
data class Failure(val message: String) : Result() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment