Last active
August 12, 2020 19:49
-
-
Save thepabloaguilar/103e4a375fb311e7b85a4a9e932fe5f7 to your computer and use it in GitHub Desktop.
[Article] Monkey Patching is not too bad - Result container example
This file contains 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
from returns.result import Failure, Result, Success | |
def is_even(number: int) -> Result[int, int]: | |
if arg % 2 == 0: | |
return Success(number) | |
return Failure(number) | |
assert is_even(2) == Success(2) | |
assert is_even(1) == Failure(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment