Besides using match
, is there an Option-like way to getOrElse
the actual content of the Right
or Left
value?
scala> val x: Either[String,Int] = Right(5)
scala> val a: String = x match {
case Right(x) => x.toString
case Left(x) => "left"
}
a: String = 5