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)
}
}
Written by Kostya Golikov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Scala
Authors
Related Tags
#scala
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#