-
-
Save jedws/2871066 to your computer and use it in GitHub Desktop.
Scala would be more fun if it had one of these...
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
final case class Schrödinger[+A, +B](private a: => A, private b: => B) extends Either[A, B] { | |
private lazy val actual : Either[A, B] = | |
if (new Random().nextBoolean()) | |
Left(a) | |
else | |
Right(b) | |
def isLeft = actual.isLeft | |
def isRight = actual.isRight | |
def left = actual.left | |
def right = actual.right | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment