Created
January 10, 2017 07:53
-
-
Save odiak/8e4967834aca6f2adf54baa403588bca 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 Either<out L, out R> { | |
class Left<out T>(val value: T) : Either<T, Nothing>() { | |
override fun equals(other: Any?): Boolean = | |
other is Left<*> && other.value == value | |
override fun hashCode(): Int = value?.hashCode() ?: 0 | |
override fun toString(): String = "Left($value)" | |
} | |
class Right<out T>(val value: T) : Either<Nothing, T>() { | |
override fun equals(other: Any?): Boolean = | |
other is Right<*> && other.value == value | |
override fun hashCode(): Int = value?.hashCode() ?: 0 | |
override fun toString(): String = "Right($value)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment