, , Either
, - : Either.left
, Either.right
.
, ( Either
Right
, left
), , map
, flatMap
, foreach
, getOrElse
..
:
randomArray.foreach { either =>
either.left.foreach(_.aMethod)
either.right.foreach(_.bMethod)
}
, , , , :
randomArray.foreach {
case Left(a) => a.aMethod
case Right(b) => b.bMethod
}