ogatatsu
12/13/2011 - 5:02 PM

joinRightサンプル

joinRightサンプル

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)