Created
December 13, 2011 17:02
-
-
Save ogatatsu/1472936 to your computer and use it in GitHub Desktop.
joinRightサンプル
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
scala> val a: Either[Exception, Either[Exception, Int]] = Right(Right(10)) | |
a: Either[Exception,Either[Exception,Int]] = Right(Right(10)) | |
scala> a.joinRight | |
res0: Either[Exception,Int] = Right(10) | |
scala> val b: Either[Exception, Either[Exception, Int]] = Right(Left(new Exception("a"))) | |
b: Either[Exception,Either[Exception,Int]] = Right(Left(java.lang.Exception: a)) | |
scala> b.joinRight | |
res1: Either[Exception,Int] = Left(java.lang.Exception: a) | |
scala> val c: Either[Exception, Either[Exception, Int]] = Left(new Exception("a")) | |
c: Either[Exception,Either[Exception,Int]] = Left(java.lang.Exception: a) | |
scala> c.joinRight | |
res2: Either[Exception,Int] = Left(java.lang.Exception: a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment