Last Updated: September 09, 2019
·
586
· lazyval

Trully Either

You can write Either type not only as Either[T,U], but as T Either U
For example:

def castToInt(s: String): Exception Either Int = {
  try {
    Right(s.toInt)
  } catch {
    case nfe: NumberFormatException => Left(nfe)
  }
}